DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

setclock(ADM)


setclock, setclk -- set the system clock or the real-time clock

Syntax

/etc/setclock [ -t ] [ time ]

/etc/setclk [ -j | -p | -r | -s ] [ -v ] [ -c rtcdev ] [ -d allowdiff ]

Description

The setclock command can be used to set the battery-powered hardware clock, also called the ``Real-Time'' clock (RTC), to the specified time. If time is not specified, setclock displays the current RTC time.

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

or

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:


OFFSET
difference in seconds between the RTC time and UTC. Used by setclk to translate the RTC time to UTC time whenever the RTC is read. Each time the RTC is re-written by setclk, OFFSET is recalculated based on the TZ environment variable setting for the user running setclk.

TIME
epoch time at which the RTC was last updated by setclk. Provided for informational purposes.

An example /etc/rtc.data file on a system running in the PST time zone might look something like:

   OFFSET=25200
   TIME=1126692061

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 2005-09-14 03:01:01.

Options

setclock takes the following option:

-t
optionally specify the century and/or the second, using the form [[CC]YY]MMDDhhmm[.SS].

 

setclk takes the following options:


-c rtcdev
Specifies the device, rtcdev, that allows access to the RTC; the default device is /dev/clock.

-d allowdiff
If the difference between system and RTC time is less than or equal to allowdiff seconds, do not reset.

-j
Jump: resynchronize the system time using the difference between when the time was last set and the current time. This adjusts the time when a system with Power Management has Resumed after being in a Frozen state.

-p
Print only: show the RTC and system times and the difference in seconds between them. Does not change the times.

-r
Set the RTC from the system time.

-s
Set the system time from the RTC. This is the default action of setclk.

-v
Verbose: show the RTC and system times and the difference in seconds between them before they are synchronized.
The -j, -p, -r, and -s options cannot be used together.

Examples

Set the RTC to 15:03 on August 26, 2006 using setclock:

/etc/setclock -t 200608261503

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:

/etc/setclk -d1

Reset the RTC from the system clock if there are more than 1,200 seconds between their values:

/etc/setclk -rd1200

Limitations

Not all computers have Real-Time Clocks. Refer to your computer's hardware reference manual.

Files


/dev/clock
device file access to RTC

/etc/rtc.data
RTC parameters file

See also

asktime(ADM), clock(F), cmos(ADM), date(C), rtc(HW), sysi86(S)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 MP4 -- October 2005