Controlling the OS (software) clock and HW (BIOS) clock:
Misc:
Jargon:
hardware clock, HW clock, real-time clock, RTC, RT clock, BIOS clock, CMOS clock:
This is a battery-powered clock on that runs even when the computer is turned off or unpowered. It is usually
quite inaccurate. It is normally only used to initialize the "OS clock" during bootup. However, software is
available which can sync the OS clock to an external source (via a network or HW port) and this software can
usually update the HW clock occasionally. Also, the HW clock can be made to provide interrupts at various
frequencies for custom timing needs.
software clock, SW clock, system clock, OS clock: This is simply a timer-interrupt-driven software
counter. The kernel controls this clock and keeps several related numbers that may be viewed and changed
with the "adjtimex" (or other programs like "xntpd"). The numbers include a drift estimate which can be
used to reduce the OS clock drift.
UTC: Universal Time, Coordinated. Almost the same as GMT. Most of the Internet runs on UTC.
The theory link below [now broken] has much more info.
Other resources:
-
Clock mini-HOWTO  How to set and keep your clock on time.
-
rtc.txt - notes on how to use the Real Time Clock (aka CMOS clock) driver.
-
The man page for hwclock (or clock). Has explaination of HW & OS clocks and their use.
-
The "date" entry of the "info" command (try "info date") has the best info on date strings, etc.
-
The man pages of the other clock commands listed below.
-
sunsite's "time" dir  Time-related programs.
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):
-
Note: I read about these and am using chronyd for OS clock and syncing HW clock with hwclock as best method.
-
adjtime: (HW clock only) Used to adjust the HW clock based on a drift estimate, often at each bootup.
-
adjtimex: (OS clock only) Used to control the OS clock, including drift.
-
clock: (both clocks) This is a softlink to the hwclock program (on my Red Hat OS).
-
chronyd, chronyc: (both clocks) Sets and corrects the drift of both clocks using intermittent
Internet connections or manual entry. Designed to be easier to use and more functional than xntpd.
Mainly lacks xntpd's ability to be controlled by external reference clocks like GPS receivers.
-
date: (OS clock only) Can be used to set the OS clock.
-
hwclock (both clocks): Can be used to set HW clock to system clock and vice-versa.
Reads and writes /etc/adjtime to keep track of and adjust for drift.
-
netdate: Sets the OS clock via the Internet. Selects "best" of specified sources. Warns of bad bug.
-
nist: Sets the OS clock via the Internet. (lastest is 2.0 from 08aug95?)
-
nisttime: Sets the OS clock by calling the National Institute
of Standards or by calling the U.S. Naval Observatory. (latest is 5.3 from 15apr95?)
-
ntp:
-
rdate: Someone said "rdate -s www.llnl.gov" sets clock from Atomic clock at Lawrence Livermore Labs.
Without the "-s" it just shows the retrieved time.
-
set2wwv: Sets OS clock from WWV (latest is 0.0-01 from 19980427)
-
set_time: Sets OS clock from Internet (latest is 1.2 from 19941004)
-
setclock: (set hardware (CMOS) clock from operating system clock).
A Red Hat script which uses /etc/sysconfig/clock to consider time zone.
This script is partially incompatible with the "clock" command it calls;
it uses a nonexistant "-A" option.
-
timeconfig - A Red Hat tool. The RH control-panel and linuxconf also have time gizmos.
-
timed: A BSD program for syncing OS clocks of networked computers.
Time-Zone Considerations:
-
People in the know recommend that you keep your HW clock in UTC unless another OS insists otherwise. UTC
will tend to give you fewer time configuration problems.
-
The -u and --utc options of hwclock and clock need to be used when setting either clock from the other
when the HW clock is kept in UTC.
-
The timezone configuration scheme is very distribution-dependent.
Time & Date (but not clock) commands:
Displaying the OS (software) clock graphically:
Other programs:
-
xclock: Basic clock display (analog or digital with day and date).
-
twclock: This allows selection of local time, UTC, or time in major world cities. The display uses
three vertical sliders (with adjacent numbers) to show the hours, minutes, and seconds. The selection
of world cities crashed for the executable I "make"ed on my system, but there is a version the
Debian team has worked on that might work better. (I might have a glibc problem.)
-
Follow sunsite link above for more programs.
Time theory:
-
"International Standard Date and Time Notation"; Good. [link broke; search web]
Last Modified 11-Feb-1999
End of page.