hwclock - Unix, Linux Command



NAME

hwclock - query and set the hardware clock (RTC)

SYNOPSIS

hwclock [functions] [options]

DESCRIPTION

hwclock 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.

OPTIONS

TAG DESCRIPTION
-u, --utc --localtime 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 hwclock.
--noadjfile disables the facilities provided by /etc/adjtime. hwclock will not read nor write to that file with this option. Either --utc or --localtime must be specified when using this option.

--adjfile=filename overrides the default /etc/adjtime.
-f, --rtc=filename overrides the default /dev file name, which is /dev/rtc on many platforms but may be /dev/rtc0, /dev/rtc1, and so on.
--directisa is meaningful only on an ISA machine or an Alpha (which implements enough of ISA to be, roughly speaking, an ISA machine for hwclock's purposes). For other machines, it has no effect.
--badyear 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.
--srm This option is equivalent to --epoch=1900 and is used to specify the most common epoch on Alphas with SRM console.

Files cannot be extracted from a thin hwclockchive.
--arc 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).
--jensen --funky-toy 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 hwclock should be able to determine by itself what it's running on, at least when /proc is mounted.
--test Do everything except actually updating the Hardware Clock or anything else. This is useful, especially in conjunction with --debug, in learning about hwclock.
--debug Display a lot of information about what hwclock is doing internally. Some of its function is complex and this output can help you understand how the program works.

EXAMPLES

Example-1:

To Display Hardware Clock Date and Time

# hwclock

# hwclock -r

# hwclock --show

output:

Sat 07 Jan 2017 06:17:43 PM IST  -0.146610 seconds

Example-2:

To Set Hardware Clock Date and Time Manually:

#  hwclock --set --date 1/1/2017

output:

# hwclock -r
Sun 01 Jan 2017 12:00:03 AM IST  -0.208884 seconds

Example-3:

To run hwclock Debug Mode

# hwclock --systohc --debug

# hwclock -hctosys --debug

# hwclock --setepoch --epoch=1952

output:

# hwclock --systohc --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 1483209000 seconds after 1969
Last calibration done at 1483209000 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2016/12/31 18:30:49
Hw clock time : 2016/12/31 18:30:49 = 1483209049 seconds since 1969
Time elapsed since reference time has been 0.809062 seconds.
Delaying further to reach the new time.
Setting Hardware Clock to 12:49:58 = 1483793398 seconds since 1969
ioctl(RTC_SET_TIME) was successful.
Not adjusting drift factor because it has been less than a day since the last calibration.

Print
Advertisements