|Linux / Unix Command: hwclock|
NAMEhwclock - query and set the hardware clock (RTC)
SYNOPSIShwclock -r or hwclock --show
hwclock -w or hwclock --systohc
hwclock -s or hwclock --hctosys
hwclock -a or hwclock --adjust
hwclock -v or hwclock --version
hwclock --set --date=newdate
hwclock --setepoch --epoch=year
[-u|--utc] --localtime --noadjfile --directisa --test [-D|--debug]
and arcane options for DEC Alpha:
[-A|--arc] [-J|--jensen] [-S|--srm] [-F|--funky-toy]
Minimum unique abbreviations of all options are acceptable.
Also, -h asks for a help message.
DESCRIPTIONhwclock is a tool for accessing the Hardware Clock. You can display the current time, set the Hardware Clock to a specified time, set the Hardware Clock to the System Time, and set the System Time from the Hardware Clock.
You can also run hwclock periodically to insert or remove time from the Hardware Clock to compensate for systematic drift (where the clock consistently gains or loses time at a certain rate if left to run).
OPTIONSYou need exactly one of the following options to tell hwclock what function to perform:
Read the Hardware Clock and print the time on Standard Output.
The time shown is always in local time, even if you keep your Hardware Clock
in Coordinated Universal Time. See the
- Set the Hardware Clock to the time given by the --date option.
Set the System Time from the Hardware Clock.
Also set the kernel's timezone value to the local timezone as indicated by the TZ environment variable and/or /usr/share/zoneinfo, as tzset(3) would interpret them. The obsolete tz_dsttime field of the kernel's timezone value is set to DST_NONE. (For details on what this field used to mean, see settimeofday(2).)
This is a good option to use in one of the system startup scripts.
- Set the Hardware Clock to the current System Time.
- Add or subtract time from the Hardware Clock to account for systematic drift since the last time the clock was set or adjusted. See discussion below.
Print out standard output the kernel's Hardware Clock epoch value.
This is the number of years into AD to which a zero year value in the
Hardware Clock refers. For example, if you are using the convention
that the year counter in your Hardware Clock contains the number of
full years since 1952, then the kernel's Hardware Counter epoch value
must be 1952.
This epoch value is used whenever hwclock reads or sets the Hardware Clock.
- Set the kernel's Hardware Clock epoch value to the value specified by the --epoch option. See the --getepoch option for details.
- Print the version of hwclock on Standard Output.
You need this option if you specify the
option. Otherwise, it is ignored.
This specifies the time to which to set the Hardware Clock.
The value of this option is an argument to the
hwclock --set --date=9/22/96 16:45:05
The argument is in local time, even if you keep your Hardware Clock in Coordinated Universal time. See the --utc option.
Specifies the year which is the beginning of the Hardware Clock's
epoch. I.e. the number of years into AD to which a zero value in the
Hardware Clock's year counter refers. It is used together with
the --setepoch option to set the kernel's idea of the epoch of the
Hardware Clock, or otherwise to specify the epoch for use with
direct ISA access.
For example, on a Digital Unix machine:
hwclock --setepoch --epoch=1952
The following options apply to most functions.
Indicates that the Hardware Clock is kept in Coordinated Universal
Time or local time, respectively. It is your choice whether to keep
your clock in UTC or local time, but nothing in the clock tells which
you've chosen. So this option is how you give that information to
If you specify the wrong one of these options (or specify neither and take a wrong default), both setting and querying of the Hardware Clock will be messed up.
If you specify neither --utc nor --localtime , the default is whichever was specified the last time hwclock was used to set the clock (i.e. hwclock was successfully run with the --set , --systohc , or --adjust options), as recorded in the adjtime file. If the adjtime file doesn't exist, the default is local time.
disables the facilities provided by
will not read nor write to that file with this option. Either
must be specified when using this option.
is meaningful only on an ISA machine or an Alpha (which implements enough
of ISA to be, roughly speaking, an ISA machine for
purposes). For other machines, it has no effect. This option tells
to use explicit I/O instructions to access the Hardware Clock.
Without this option,
will try to use the /dev/rtc device (which it assumes to be driven by the
rtc device driver). If it is unable to open the device (for read), it will
use the explicit I/O instructions anyway.
The rtc device driver was new in Linux Release 2.
Indicates that the Hardware Clock is incapable of storing years outside
the range 1994-1999. There is a problem in some BIOSes (almost all
Award BIOSes made between 4/26/94 and 5/31/95) wherein they are unable
to deal with years after 1999. If one attempts to set the year-of-century
value to something less than 94 (or 95 in some cases), the value that
actually gets set is 94 (or 95). Thus, if you have one of these machines,
cannot set the year after 1999 and cannot use the value of the clock as
the true time in the normal way.
To compensate for this (without your getting a BIOS update, which would definitely be preferable), always use --badyear if you have one of these machines. When hwclock knows it's working with a brain-damaged clock, it ignores the year part of the Hardware Clock value and instead tries to guess the year based on the last calibrated date in the adjtime file, by assuming that that date is within the past year. For this to work, you had better do a hwclock --set or hwclock --systohc at least once a year!
Though hwclock ignores the year value when it reads the Hardware Clock, it sets the year value when it sets the clock. It sets it to 1995, 1996, 1997, or 1998, whichever one has the same position in the leap year cycle as the true year. That way, the Hardware Clock inserts leap days where they belong. Again, if you let the Hardware Clock run for more than a year without setting it, this scheme could be defeated and you could end up losing a day.
hwclock warns you that you probably need --badyear whenever it finds your Hardware Clock set to 1994 or 1995.
- This option is equivalent to --epoch=1900 and is used to specify the most common epoch on Alphas with SRM console.
- This option is equivalent to --epoch=1980 and is used to specify the most common epoch on Alphas with ARC console (but Ruffians have epoch 1900).
These two options specify what kind of Alpha machine you have. They
are invalid if you don't have an Alpha and are usually unnecessary
if you do, because
should be able to determine by itself what it's
running on, at least when
(If you find you need one of these options to make
work, contact the maintainer to see if the program can be improved
to detect your system automatically. Output of `hwclock --debug'
and `cat /proc/cpuinfo' may be of interest.)
--jensen means you are running on a Jensen model.
--funky-toy means that on your machine, one has to use the UF bit instead of the UIP bit in the Hardware Clock to detect a time transition. "Toy" in the option name refers to the Time Of Year facility of the machine.
- Do everything except actually updating the Hardware Clock or anything else. This is useful, especially in conjunction with --debug, in learning about hwclock.
Display a lot of information about what
is doing internally. Some of its function is complex and this output
can help you understand how the program works.
SEE ALSOadjtimex(8), date(1), gettimeofday(2), settimeofday(2), crontab(1), tzset(3)
Important: Use the man command (% man) to see how a command is used on your particular computer.