From 24928ffd8d6eb7f410ea0a7b4530086cecfeea6e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 25 Jan 2010 19:30:16 +0100 Subject: ntpd: explain why scripts can be run in quick succession Signed-off-by: Denys Vlasenko --- examples/var_service/ntpd/ntp.script | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'examples/var_service') 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 @@ #!/bin/sh -exec 2>/dev/null -echo "`tail -n 99 "$0.log"`" >"$0.log" - -exec >>"$0.log" -exec 2>&1 +# Note that there is no provision to prevent several copies of the script +# to be run in quick succession. In fact, it happens rather often +# if initial syncronization results in a step. +# You will see "step" and then "stratum" script runs, sometimes +# as close as only 0.002 seconds apart. +# +# Script should be ready to deal with this. dt=`date '+%Y-%m-%d %H:%M:%S'` @@ -13,17 +15,23 @@ if test x"$stratum" != x"" \ && test 4 -ge "$stratum" \ && test 128 -le "$poll_interval" \ ; then + echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" echo "$dt: $1"\ "freq_drift_ppm=$freq_drift_ppm"\ "offset=$offset"\ "stratum=$stratum"\ "poll_interval=$poll_interval,"\ - "setting hardware clock" + "setting hardware clock"\ + >>"$0.log.$$" + mv -- "$0.log.$$" "$0.log" exec hwclock --systohc fi +echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$" echo "$dt: $1"\ "freq_drift_ppm=$freq_drift_ppm"\ "offset=$offset"\ "stratum=$stratum"\ "poll_interval=$poll_interval"\ + >>"$0.log.$$" +mv -- "$0.log.$$" "$0.log" -- cgit v1.2.3