/etc/setclk [ -j | -p | -r | -s ] [ -v ] [ -c rtcdev ] [ -d allowdiff ]
Note that date(C) is the preferred command for adjusting the RTC to a specific time. Use setclock, however, on systems where the default kernel configuration has been modified so the RTC and system clock are not automatically synchronized.
To set the RTC time, run:
# setclock MMDDhhmmYY
# setclock -t [[CC]YY]MMDDhhmm[.SS]
CC is the first two digits of the year (00-99), YY is the last two digits of the year (00-99), MM is the month (01-12), DD is the day (01-31), hh is the hour (00-23), mm is the minute (00-59), and SS is the second (00-59). If YY is not supplied, it is taken from the current system clock.
The setclk command can be used to keep the RTC and the system clock in sync. (Note that the kernel automatically synchronizes the RTC and the system clock, so running setclk manually is not usually necessary, unless your system configuration has been modified to disable this operation.) By default, the system clock is updated based on the RTC. asktime(ADM) uses setclk to perform this operation at system startup. setclk is also used to update the RTC from the system clock at changeover to and from Daylight Saving Time. This operation is performed automatically by root's crontab(C).
setclk uses the offset between the current time zone and ``Coordinated Universal Time'' (UTC), recorded in the /etc/rtc.data file, to keep the system clock and the RTC synchronized. The /etc/rtc.data file contains the following variables:
An example /etc/rtc.data file on a system running in the PST time zone might look something like:
In this example, the TIME variable indicates that
setclk ran at epoch time
2005-09-14 10:01:01 UTC
1970-01-01 00:00:00 UTC plus 1,126,692,061 seconds).
The OFFSET variable shows that setclk
updated the RTC to UTC time
minus 25,200 seconds (7 hours), or
setclk takes the following options:
Set both the system clock
to 15:03:45 on August 26, 2006
using date (with the -t option),
and use setclk to synchronize the RTC with
the system clock:
date -t 200608261503.45; /etc/setclk -r
At system startup, asktime resynchronizes the
system clock from the RTC
if there is more than one second difference between them:
Reset the RTC from the system clock if there are more
than 1,200 seconds between their values: