[ntp:questions] ntpd behavior to replace ntpdate single shot

Matthew Weber matthew.weber at rockwellcollins.com
Wed Oct 24 13:49:14 UTC 2018


I'm working on an update to an init script for Buildroot and was
wondering if I can accomplish the following sequence with a single
call to ntpd.

Original sequence
-------------------------------------
ntpdate <server>   #blocks
ntpd -g
#time is valid

Updated scenario #1 - Time is never initially set and I always
timeout. I believe it's a step issue and I tried including the -x and
-G.
-------------------------------------
ntpd -g -x -G -w 15   # blocks from 15sec, times out and continues
# time is not valid but server lists in ntpq -p

Updated scenario #2 - Works by forcing the step information to drop
and time gets initially set and then maintained.
-------------------------------------
ntpd -gq &
# manage the pid from the one-shot with a while loop until the timeout
and kill ntpd as it would hang forever if the server can't be reached
(is there away around this?)
ntpd -g
# time is valid


More information about the questions mailing list