summaryrefslogtreecommitdiff
path: root/examples/var_service/ntpd/ntp.script (plain)
blob: 76c34bf74aed09353396478d4fb72e06c066a180
1#!/bin/sh
2
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.
8#
9# Script should be ready to deal with this.
10
11dt=`date '+%Y-%m-%d %H:%M:%S'`
12
13if test x"$stratum" != x"" \
14&& test x"$poll_interval" != x"" \
15&& test 4 -ge "$stratum" \
16&& test 128 -le "$poll_interval" \
17; then
18 echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
19 echo "$dt: $1"\
20 "freq_drift_ppm=$freq_drift_ppm"\
21 "offset=$offset"\
22 "stratum=$stratum"\
23 "poll_interval=$poll_interval,"\
24 "setting hardware clock"\
25 >>"$0.log.$$"
26 mv -- "$0.log.$$" "$0.log"
27 exec hwclock --systohc
28fi
29
30echo "`tail -n 199 -- "$0.log" 2>/dev/null`" >"$0.log.$$"
31echo "$dt: $1"\
32 "freq_drift_ppm=$freq_drift_ppm"\
33 "offset=$offset"\
34 "stratum=$stratum"\
35 "poll_interval=$poll_interval"\
36 >>"$0.log.$$"
37mv -- "$0.log.$$" "$0.log"
38