[ntp:questions] Why does ntp keep changing my conf file?

Petri Kaukasoina kaukasoina1001n57qu040 at sci.fi
Thu Sep 23 04:24:45 UTC 2010

Daniel Havey  <dhavey at yahoo.com> wrote:
>A day or even 10 hours is totally unacceptable.  This is an emulab
>like testbed.  We bring nodes into experiments, wipe them out,
>re-configure, and reboot frequently.  Even 10 minutes, would be
>extremely annoying.  So if I reboot my nodes 6 times in a day then I
>must spend an hour waiting for ntpd to do it's voodoo?

I guess it's because the Linux kernel calibrates its clock rate a bit
different in every boot. Before I succeeded in fixing that in my
systems, I used a script like below. It uses ntpdate to set time,
waits for 100 seconds, sets time again, calculates a good guess for the
frequency drift, and starts ntpd. ntpd will converge very fast then.

# NTPSERVER must be another local ntp server
# remember to stop ntpd first if running
# reset frequency offset to zero
adjtimex -f 0
# calibrate clock rate during $TIME seconds
ntpdate -sb $NTPSERVER
sleep $TIME
ADJUST=$(ntpdate -b $NTPSERVER | sed 's/.*offset \(.*\) sec.*/\1/')
# ntpdate adjusted $ADJUST seconds
FREQUENCY=$(echo "scale=3; $ADJUST * 1000000 / $TIME" | bc)
# reset the drift file and start ntpd
cp -p $DRIFTFILE ${DRIFTFILE}.previous

More information about the questions mailing list