adjtimex






adjtimex − display or set the kernel time variables

adjtimex

This program gives you raw access to the kernel time
variables.  For a machine connected to the Internet, or
equipped with a precision oscillator or radio clock, the
best way to keep the system clock correct is with xntpd(8).
For a standalone or intermittently connected machine, you
may use adjtimex instead to at least correct for systematic
drift.

     Anyone may print out the time variables, but only the
superuser may change them.

     If your computer is connected to the net, but you
prefer not to run xntpd due to its size, you might still run
it for a day or two and use adjtimex ‐print to learn what
values of tick and freq it settled on.  You could then kill
xntpd, and add a line to rc.local invoking adjtimex to set
those parameters each time you reboot.



−tick val
     Set the number of microseconds that should be added to
     the system time for each kernel tick interrupt.  There
     are supposed to be 100 ticks per second, so val should
     be close to 10000.  Increasing val by 1 speeds up the
     system clock by about 100 ppm, or 8.64 sec/day.

−frequency newfreq
     Set the system clock frequency offset to newfreq.
     newfreq can be negative or positive, and gives a much
     finer adjustment than the ‐tick switch.  The value is
     scaled such that newfreq = 1<<16 speeds up the system
     clock by about 1 ppm, or .0864 sec/day.  Thus, ‐tick
     10000 ‐newfreq 6553600 is about the same as ‐tick 10001
     ‐newfreq 0.  newfreq must be in the range
     ‐6553600...6553600 (‐100<<16...100<<16).


−singleshot adjustment
     Slew the system clock by adjustment usec.  (Its rate is
     changed temporarily by about 1 part in 2000.)

−offset val
     Add a time offset of val usec.  The kernel code adjusts
     the time gradually by val, notes how long it has been
     since the last time offset, and then adjusts the
     frequency offset to correct for the apparent drift.
     val must be in the range ‐131000...131000.











                             ‐2‐


−maxerror val
     Set maximum error (usec).

−esterror val
     Set estimated error (usec).  The maximum and estimated
     error are not used by the kernel.  They are merely made
     available to user processes via the adjtimex(2) system
     call.

−timeconstant val
     Set phase locked loop (PLL) time constant.  val
     determines the bandwidth or "stiffness" of the PLL.
     The effective PLL time constant will be a multiple of
     (1 << val).  For room‐temperature quartz oscillators,
     David Mills recommends the value 2, which corresponds
     to a PLL time constant of about 900 sec and a maximum
     update interval of about 64 sec.  The maximum update
     interval scales directly with the time constant, so
     that at the maximum time constant of 6, the update
     interval can be as large as 1024 sec.

     Values of val between zero and 2 give quick
     convergence; values between 2 and 6 can be used to
     reduce network load, but at a modest cost in accuracy.

−status val
     Set time_status variable in the kernel:
           0   the kernel should periodically set the
               CMOS clock to match the system clock
           1   insert a leap second at midnight
           2   delete a leap second at midnight
           3   leap second in progress
           4   the kernel should leave the CMOS clock alone
     Using any of the above switches automatically resets
     the status to 0.  Do not use ‐status with −singleshot.
     In that case, setting the time_status back to 4 must be
     done in a separate operation.  This is a race
     condition.  The kernel must be patched to permit using
     ‐status with −singleshot as an atomic operation.

−print
     Print the current values of the kernel time variables.
     NOTE: The time is "raw", and may be off by up to one
     timer tick (10 msec).

−help
     Print the program options.


If your system clock gained 8 seconds in 24 hours, you could
set the tick to 9999, and then it would lose 0.64 seconds a
day (that is, 1 tick unit = 8.64 seconds per day).  To
correct the rest of the error, you could set the frequency
offset to (1<<16)*0.64/.0864 = 485452.  Thus, putting the









                             ‐3‐


following in rc.local would approximately correct the system
clock:

     adjtimex ‐tick 9999 ‐freq 485452


adjtimex deals only with the system clock — the one that
runs while the computer is powered up.  To read or set the
CMOS clock, see clock(8).

Steven S. Dick <ssd@nevets.oau.org>.

/usr/src/linux/include/linux/timex.h,
/usr/src/linux/include/linux/sched.h,
/usr/src/linux/kernel/time.c, /usr/src/linux/kernel/sched.c