[ntp:questions] Re: ntp client over satellite and no CMOS battery
Bob Beers
bob.beers at gmail.com
Tue Oct 4 23:28:47 UTC 2005
Hi John
>
> It sounds like the startup script needs to wait until the net is up
> before it starts ntpd and then the client app needs to wait until the
> time is set before it starts. It should be possible with a simple
> shell script that waits until ping works before it launches ntpd.
Thanks, yes, that's the general idea. I wondered if anyone was willing
to share more specific implementation details. What I have so far:
psuedo-code:
in rc.local:
rc = ping -c 3 -w 2 $SRV
if [ $rc -eq 0 ]; then
ntpd -g -N
put checker_sh in crontab
else
put pinger_sh in crontab
fi
#and_finish_startup_scripts_so_users_can_login_if_necessary
pinger_sh:
while [ $rc -ne 0 -a $x -lt 10 ]; do
rc = ping -c3 -w 2 $SRV
if [ $rc -eq 0 ]; then
ntpd -g -N
del pinger_sh from crontab
put checker_sh in crontab
else
sleep 2
x=x+1
fi
done
checker_sh:
while [ $state <= 2 -a $x < 5]; do
state=$( ntpq -c "rv 0 state" | grep state | cut -d"=" -f2 )
if [ $state -eq 3 -o $state -eq 4 ]; then
hwclock --systohc
del checker_sh from crontab
launch time_dependent_app
else
sleep 2
x=x+1
fi
done
If someone more familiar with the behavior/states of ntpq/ntpd
could correct any glaring shortcoming with this implementation
I would be very grateful.
-Bob
More information about the questions
mailing list