Clock adjustments and adjtime

This morning, the clocks went back 1 hour from BST to GMT. This was nice, as it meant we gained an hour. However, it also means that we need to set all of the clocks back. Most of the clocks must be done manually, but computers usually adjust themselves automatically.

Unrelatedly, there can sometimes be slight problems with hardware clocks, they can systematically gain time by a couple of seconds per day, and so must be adjusted. For example, my server gains 2.072 seconds per day and must be automatically set back (you can read more about this in the hwclock(8) man page). To do this, a file called adjtime (at /var/lib/hwclock/adjtime on Arch Linux, but /etc/adjtime usually) stores the systematic drift and is used to automatically compensate for it. Usually, this works fine and ensures that the clock is correct.

The problem occurs when the clocks go back and hwclock mistakes the daylight savings time adjustment for a systematic bias in the system clock. hwclock decides to store something like -3598 seconds per day in the adjtime file, which causes the time to appear to creep backwards at around an hour per day. This is obviously not what was wanted, and can be fixed by simply removing the adjtime file:

sudo rm /etc/adjtime

All you have to do now is set your clock to the real time. I prefer to use openntpd for this, as synchronizing the time with a time server should be more accurate than entering it manually.

sudo /etc/rc.d/openntpd start

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.