SuperLinux Encyclopedia - Clocks and Time


Controlling the OS (software) clock and HW (BIOS) clock:

Misc:

Jargon:


Other resources:


  A basic method to set the system and hardware clocks:
     date           ## to see current Unix time
     clock -r       ## to see current CMOS time
     date -s TIME   ## to set system clock, where TIME is "13:44:30" or output of "date" or similar
     clock -w -u    ## to set hardware clock to UTC time from system clock in local time.
  A alternate version of the same:
     date                    ## to see current Unix time
     hwclock --show          ## to see current CMOS time
     date -s TIME            ## to set system clock, where TIME is "13:44:30" or output of "date" or similar
     hwclock --systohc --utc ## to set hardware clock to UTC time from system clock in local time.
  An advanced method (my brief untested summary):
  To get your clocks running well, do the following (assuming use of local
  time, not utc). It also assumes that no programs are running that will
  be confused by change of the OS clock.
  -- Ensure that your startup scripts do two things:
     -- Adjust the HW clock for drift (hwclock --adjust)
     -- Set the OS clock to the HW clock (hwclock --hctosys)
  -- Initialize the /etc/adjtime file and clocks thusly
     (or use a program like xntpd for several hours):
     -- Remove the /etc/adjtime file.
     -- Set the HW clock (hwclock --set --date="[date string]") which
        initializes the /etc/adjtime file.
     -- Set the OS clock (hwclock --hctosys)
     -- After several days, reset the clocks:
        -- (hwclock --set --date="[date string]") which changes 
           /etc/adjtime so the HW clock drift rate is saved.
        -- Use the adjtimex command (see man page) to adjust the
           OS clock time and drift rate parameters.
        -- Repeat as needed to correct drifts.

Clock commands (OS/SW and RT/HW clocks):

Time-Zone Considerations:

Time & Date (but not clock) commands:


Displaying the OS (software) clock graphically:

Other programs:


Time theory:


Last Modified 11-Feb-1999

End of page.