3 # Note that there is no provision to prevent several copies of the script
4 # to be run in quick succession. In fact, it happens rather often
5 # if initial syncronization results in a step.
6 # You will see "step" and then "stratum" script runs, sometimes
7 # as close as only 0.002 seconds apart.
9 # Script should be ready to deal with this.
11 dt
=`date '+%Y-%m-%d %H:%M:%S'`
13 echo "`tail -n 199 -- "$0.log
" 2>/dev/null`" >"$0.log.$$"
15 if test x
"$1" = x
"unsync" \
17 # No replies for our NTP requests were seen for some time.
19 # Among more mundate cases like network outages, this happens
20 # if we ran for a LONG time (days) and ntp server's IP has changed.
21 # ntpd has no code to re-resolve peers' addresses to IPs,
25 "syncronization lost, restarting ntpd"\
27 mv -- "$0.log.$$" "$0.log"
32 if test x
"$stratum" != x
"" \
33 && test x
"$poll_interval" != x
"" \
34 && test 4 -ge "$stratum" \
35 && test 128 -le "$poll_interval" \
38 "freq_drift_ppm=$freq_drift_ppm"\
41 "poll_interval=$poll_interval,"\
42 "setting hardware clock"\
44 mv -- "$0.log.$$" "$0.log"
45 exec hwclock --systohc
49 "freq_drift_ppm=$freq_drift_ppm"\
52 "poll_interval=$poll_interval"\
54 mv -- "$0.log.$$" "$0.log"