ntp.script 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. # Note that there is no provision to prevent several copies of the script
  3. # to be run in quick succession. In fact, it happens rather often
  4. # if initial syncronization results in a step.
  5. # You will see "step" and then "stratum" script runs, sometimes
  6. # as close as only 0.002 seconds apart.
  7. #
  8. # Script should be ready to deal with this.
  9. dt=`date '+%Y-%m-%d %H:%M:%S'`
  10. if test x"$stratum" != x"" \
  11. && test x"$poll_interval" != x"" \
  12. && test 4 -ge "$stratum" \
  13. && test 128 -le "$poll_interval" \
  14. ; then
  15. echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
  16. echo "$dt: $1"\
  17. "freq_drift_ppm=$freq_drift_ppm"\
  18. "offset=$offset"\
  19. "stratum=$stratum"\
  20. "poll_interval=$poll_interval,"\
  21. "setting hardware clock"\
  22. >>"$0.log.$$"
  23. mv -- "$0.log.$$" "$0.log"
  24. exec hwclock --systohc
  25. fi
  26. echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
  27. echo "$dt: $1"\
  28. "freq_drift_ppm=$freq_drift_ppm"\
  29. "offset=$offset"\
  30. "stratum=$stratum"\
  31. "poll_interval=$poll_interval"\
  32. >>"$0.log.$$"
  33. mv -- "$0.log.$$" "$0.log"