aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-25 19:30:16 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-25 19:30:16 +0100
commit24928ffd8d6eb7f410ea0a7b4530086cecfeea6e (patch)
treefa0c4b0cdcebb2c4a9f8d5aefcd42fcafcbb89da /examples
parent3581c625151d25d8e1cbc80c44337d398d97cf42 (diff)
downloadbusybox-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')
-rwxr-xr-xexamples/var_service/ntpd/ntp.script20
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
3exec 2>/dev/null 3# Note that there is no provision to prevent several copies of the script
4echo "`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.
6exec >>"$0.log" 6# You will see "step" and then "stratum" script runs, sometimes
7exec 2>&1 7# as close as only 0.002 seconds apart.
8#
9# Script should be ready to deal with this.
8 10
9dt=`date '+%Y-%m-%d %H:%M:%S'` 11dt=`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
23fi 28fi
24 29
30echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
25echo "$dt: $1"\ 31echo "$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.$$"
37mv -- "$0.log.$$" "$0.log"