[RndTbl] NTP - It's about time!...
Gilbert E. Detillieux
gedetil at cs.umanitoba.ca
Mon Nov 19 18:11:59 CST 2001
(Sorry, I couldn't resist the bad pun.)
Just a quick note to say I've updated the write-up of the November MUUG
meeting on our web site...
http://www.muug.mb.ca/meetings/
... to include links to the web sites mentioned in the meeting, including
the one for NTP.
Also, someone had asked whether ntpd under Linux would update the hardware
(CMOS) clock or not. It doesn't - it only deals with the system clock (the
internal kernel clock that counts time elapsed since a particular epoch).
Unfortunately, within Linux, those two clocks are kept independent, and can
actually be keeping different time.
The solution, if you want to make sure your hardware clock is at least
periodically synched up to the system clock, would be to run a cron job to
do this via the "hwclock" command. I've attached a simple little script
that does the job, and takes things into account like whether the clock is
keeping time in UTC (GMT) or local time, and whether the clock is in ARC
format (used by certain Alpha-based systems) or not. The script used to run
the "rdate" command to update the system clock first, but I've commented
that out, since you'd obviously not want to do that if you're running NTP.
--
Gilbert E. Detillieux E-mail: <gedetil at cs.umanitoba.ca>
Dept. of Computer Science Web: http://www.cs.umanitoba.ca/~gedetil/
University of Manitoba Phone: (204)474-8161
Winnipeg, MB, CANADA R3T 2N2 Fax: (204)474-7609
-------------- next part --------------
#!/bin/bash
# Synchronize to a time server, since our clock is not accurate:
# (Now done via ntpdate and ntpd.)
#rdate -s timehost
# Write the clock setting back to the CMOS clock:
# (Cribbed from rc.sysinit file.)
ARC=0
SRM=0
UTC=0
if [ -f /etc/sysconfig/clock ]; then
. /etc/sysconfig/clock
# convert old style clock config to new values
if [ "${CLOCKMODE}" = "GMT" ]; then
UTC=true
elif [ "${CLOCKMODE}" = "ARC" ]; then
ARC=true
fi
fi
CLOCKFLAGS="--systohc"
case "$UTC" in
yes|true)
CLOCKFLAGS="$CLOCKFLAGS -u";
;;
esac
case "$ARC" in
yes|true)
CLOCKFLAGS="$CLOCKFLAGS -A";
;;
esac
case "$SRM" in
yes|true)
CLOCKFLAGS="$CLOCKFLAGS -S";
;;
esac
/sbin/hwclock $CLOCKFLAGS
# Make sure we exit with success code, regardless of what happened:
exit 0
More information about the Roundtable
mailing list