17.1 Adjtimex

HISTORIC

The adjtimex command can be used to counter systematic drift in the system clock. It is tricky to fine tune, and it is recommended that you use the network time protocol (Section 17.6) instead.

The command communicates with the kernel to change the number of ticks in a day (default is 10000 which corresponds to about 8.64 seconds per tick) and the frequency (default is 0) of the system clock. In Debian you can use the command adjtimexconfig to automatically tune the tick and frequency to match the accuracy of the hardware clock (assumed to be accurate) and so that the change has effect on each boot. Alternatively, override the automatic settings by editting /etc/adjtimex.conf.

I a system where the system clock was losing (very) roughly 1 second per hour. (The hardware clock seemed to lose nearly one second each day.) Not too much on the face of it but considering the machine is rarely rebooted this can become a significant drift. For this machine a tick of 10002 and a frequency of 4000000 set the clock accurately:

$ sudo adjtimex --tick 10002 --freq 4000000

On an old 486/DX66 the system clock was gaining about 22 seconds in 24 hours and the hardware clock gaining about 10 seconds in 24 hours. Removing 3 ticks had the dramatic effect of making the system clock pretty accurate.

$ sudo adjtimex --tick=9997

On yet another computer the system clock was losing about 1 second every hour (16 seconds in 24 hours). Running adjtimexconfig:

$ sudo adjtimexconfig

should adjust the ticks for the system clock against the hardware clock which is assumed to be, and generally is, accurate. However, after 24 hours the system clock was still about 5 seconds slow. The hwclock was also a few seconds out after a weekend. The parameters in /etc/adjtimex.conf were:

  TICK=10000
  FREQ=1653461

At 1pm one day the clocks were reset with adjustment:

$ sudo adjtimex --tick 10002 --freq 0

See how it goes. If it works then update /Path{/etc/adjtimex.conf} to match this.

At 4pm the following day the clock was 10 seconds slow. So reset the clock and try:

$ sudo adjtimex --tick 10002 --freq 4000000

Today we avoid all this fidling around by using the network time protocol (NTP) as explained in Section 17.6.



Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0