setclock(ADM)


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

Syntax

/etc/setclock [ time ]

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

Description

setclock sets the battery-powered, real-time time of day clock (RTC) to the given time. If time is not given, setclock displays the current RTC time.

time must be a combination of digits with the form:

[[CC]YY]MMDDhhmm

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), and mm is the minute (00-59). If a year is not supplied, it is taken from the current system time. A drawback of setclock is that the second cannot be specified, and is always set to 00. For this reason, you should instead use setclk and date(C) with the -t option to set the RTC and system clocks.

asktime(ADM) uses setclk to set the system time maintained by the kernel from the RTC at system startup. setclk can also set the RTC from the system clock; for example, to update the RTC at changeover to or from Daylight Saving Time.

setclk takes the following options:


-c rtcdev
Specify 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. Do 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.

-t
Calls date(C) with the -t flag (which includes the century).

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

Examples

Set the system clock to 15:03 on August 26, 2005 using setclock:

/etc/setclock 200508261503

Set both the system clock to 15:03:45 on August 26, 2005 using date (with the -t option), and use setclk to synchronize the RTC with the system clock:

date -t 200508261503.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 1200 seconds between their values:

/etc/setclk -rd1200

Limitations

Not all computers have real-time clocks. Refer to your computer's hardware reference manual.

The command date `setclock` cannot set the second in the system clock because of the granularity of the /dev/clock device. Use setclk to synchronize the system clock with the RTC.

Files


/dev/clock
device file access to real-time clock

See also

asktime(ADM), clock(F), cmos(ADM), date(C), rtc(HW), sysi86(S-osr5)
© 2007 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 12 June 2007