[PLUG] Future Time Stamp: Clocks FUBAR

Jim Garrison jhg at jhmg.net
Fri Jan 16 21:26:21 PST 2015


One thing to be aware of is that in Linux, the HW clock runs
independently of the SW clock.  The idea is that you are using a good
time synch tool (like NTPD) which constantly updates the SW clock
frequency keeping it in sync with the time server. This makes the SW
clock a MUCH better time source than the HW clock of a typical PC
since after settling down it will rarely drift more than a few
milliseconds before being resynchronized.

The HW clock is SET from the SW clock at shutdown, and is used to set
the initial value of the SW clock at bootup.  The HW clock is used
only as a cache for a reasonable approximation of the time, and after
booting NTPD is expected to adjust for any HW clock drift while the OS
was not running.

The only way the two ever sync during normal operation (i.e. not in
the context of a shutdown or bootup) is via the hwclock(8) command.
So, unless you intervene manually the SW clock should not jump around
between reboots, regardless of what the HW clock does.  That's sort
of a fundamental assumption in the kernel -- time is smooth.

If you see timestamp jumps at reboots, the culprit is almost surely
the NVRAM battery on the motherboard.  Just a few days ago I saw this on
a 5-year old system.  I got a BIOS warning during a reboot and,
curiously, the clock had reset itself to 00:00:00 *without changing
the date* (i.e. the date was still correct).

Let's say something similar happened to you.  Your system wakes up and
sets the (wrong) time from HW clock, then NTPD queries the servers and
gets an offset that's too big.  You should see a message in your
system log about NTPD refusing to reset the clock.

The other possibility is that the time server you are syncing to had a
glitch and was sending out the wrong time.  That's highly unlikely
though, and assuming you query at least 3 servers, NTPD is smart enough
to discard the outlier.  You do have at least 3 servers in your NTPD
config, right?

Now, if you're seeing random time jumps without a reboot then something
else is seriously broken.

-- 
Jim Garrison (jhg at acm.org)
PGP Keys at http://www.jhmg.net RSA 0x04B73B7F DH 0x70738D88



More information about the PLUG mailing list