CLOCK(8)

NAME
clock - manipulate the CMOS clock

SYNOPSIS
/etc/clock [ -u ] -r
/etc/clock [ -u ] -w
/etc/clock [ -u ] -s
/etc/clock [ -u ] -a

DESCRIPTION
clock manipulates the CMOS clock in variaous ways, allowing it to be read or written, and allowing synchronization between the CMOS clock and the kernel's version of the system time.

OPTIONS

-u  Indicates that the CMOS clock is set to Universal Time.

-r  Read CMOS clock and print the result to stdout.

-w  Write the system time into the CMOS clock.

-s  Set the system time from the CMOS clock.

-a  Set the system time from the CMOS clock, adjusting the time to correct for systematic error, and writting it back into the CMOS clock.

    This option uses the file /etc/adjtime to determine how the clock changes. It contains three numbers:
    The first number is the correction in seconds per day (for example, if your clock runs 5 seconds fast each day, the first number should read -5.0).

    The second number tells when clock was last used, in seconds since 1/1/1970.

    The third number is the remaining part of a second that was left over after the last adjustment.

    The following instructions are from the source code:

    a)  create a file /etc/adjtime containing as the first and only line: '0.0 0 0.0'

    b)  run clock -au or clock -a, depending on whether your CMOS is in Universal or Local Time. This updates the second number.

    c)  set your system time using the date command.

    d)  update your CMOS time using clock -wu or clock -w

    e)  replace the first number in /etc/adjtime by your correction.

    f)  put the command clock -au or clock -a in your /etc/rc.local, or let cron(8) start it regularly.

FILES
/etc/adjtime
/etc/rc.local

BUGS
This is from the source code: I did have a few occasions during testing where every number read from the CMOS was 165 (BCD=0xff). In that case mktime fails, and all kinds of weird things happen. I put in some trapping code, although I know that this shouldn't (can't?) happen.

AUTHORS
V1.0: Charles Hedrick, hedrick@cs.rutgers.edu, Apr 1992 V1.1: Modified for clock adjustments, Rob Hooft, hooft@chem.ruu.nl, Nov 1992