diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-25 19:30:16 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-25 19:30:16 +0100 |
commit | 24928ffd8d6eb7f410ea0a7b4530086cecfeea6e (patch) | |
tree | fa0c4b0cdcebb2c4a9f8d5aefcd42fcafcbb89da /examples/var_service/ntpd | |
parent | 3581c625151d25d8e1cbc80c44337d398d97cf42 (diff) | |
download | busybox-w32-24928ffd8d6eb7f410ea0a7b4530086cecfeea6e.tar.gz busybox-w32-24928ffd8d6eb7f410ea0a7b4530086cecfeea6e.tar.bz2 busybox-w32-24928ffd8d6eb7f410ea0a7b4530086cecfeea6e.zip |
ntpd: explain why scripts can be run in quick succession
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples/var_service/ntpd')
-rwxr-xr-x | examples/var_service/ntpd/ntp.script | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/examples/var_service/ntpd/ntp.script b/examples/var_service/ntpd/ntp.script index 90299ae8e..76c34bf74 100755 --- a/examples/var_service/ntpd/ntp.script +++ b/examples/var_service/ntpd/ntp.script | |||
@@ -1,10 +1,12 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | exec 2>/dev/null | 3 | # Note that there is no provision to prevent several copies of the script |
4 | echo "`tail -n 99 "$0.log"`" >"$0.log" | 4 | # to be run in quick succession. In fact, it happens rather often |
5 | 5 | # if initial syncronization results in a step. | |
6 | exec >>"$0.log" | 6 | # You will see "step" and then "stratum" script runs, sometimes |
7 | exec 2>&1 | 7 | # as close as only 0.002 seconds apart. |
8 | # | ||
9 | # Script should be ready to deal with this. | ||
8 | 10 | ||
9 | dt=`date '+%Y-%m-%d %H:%M:%S'` | 11 | dt=`date '+%Y-%m-%d %H:%M:%S'` |
10 | 12 | ||
@@ -13,17 +15,23 @@ if test x"$stratum" != x"" \ | |||
13 | && test 4 -ge "$stratum" \ | 15 | && test 4 -ge "$stratum" \ |
14 | && test 128 -le "$poll_interval" \ | 16 | && test 128 -le "$poll_interval" \ |
15 | ; then | 17 | ; then |
18 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" | ||
16 | echo "$dt: $1"\ | 19 | echo "$dt: $1"\ |
17 | "freq_drift_ppm=$freq_drift_ppm"\ | 20 | "freq_drift_ppm=$freq_drift_ppm"\ |
18 | "offset=$offset"\ | 21 | "offset=$offset"\ |
19 | "stratum=$stratum"\ | 22 | "stratum=$stratum"\ |
20 | "poll_interval=$poll_interval,"\ | 23 | "poll_interval=$poll_interval,"\ |
21 | "setting hardware clock" | 24 | "setting hardware clock"\ |
25 | >>"$0.log.$$" | ||
26 | mv -- "$0.log.$$" "$0.log" | ||
22 | exec hwclock --systohc | 27 | exec hwclock --systohc |
23 | fi | 28 | fi |
24 | 29 | ||
30 | echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" | ||
25 | echo "$dt: $1"\ | 31 | echo "$dt: $1"\ |
26 | "freq_drift_ppm=$freq_drift_ppm"\ | 32 | "freq_drift_ppm=$freq_drift_ppm"\ |
27 | "offset=$offset"\ | 33 | "offset=$offset"\ |
28 | "stratum=$stratum"\ | 34 | "stratum=$stratum"\ |
29 | "poll_interval=$poll_interval"\ | 35 | "poll_interval=$poll_interval"\ |
36 | >>"$0.log.$$" | ||
37 | mv -- "$0.log.$$" "$0.log" | ||