Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   hwclock    ( 8 )

утилита времени (time clocks utility)

Параметры (Options)

--adjfile=filename
           Override the default /etc/adjtime file path.

--date=date_string This option must be used with the --set or --predict functions, otherwise it is ignored.

hwclock --set --date='16:45'

hwclock --predict --date='2525-08-14 07:11:05'

The argument must be in local time, even if you keep your Hardware Clock in UTC. See the --localtime option. Therefore, the argument should not include any timezone information. It also should not be a relative time like "+5 minutes", because hwclock's precision depends upon correlation between the argument's value and when the enter key is pressed. Fractional seconds are silently dropped. This option is capable of understanding many time and date formats, but the previous parameters should be observed.

--delay=seconds This option can be used to overwrite the internally used delay when setting the clock time. The default is 0.5 (500ms) for rtc_cmos, for another RTC types the delay is 0. If RTC type is impossible to determine (from sysfs) then it defaults also to 0.5 to be backwardly compatible.

The 500ms default is based on commonly used MC146818A-compatible (x86) hardware clock. This Hardware Clock can only be set to any integer time plus one half second. The integer time is required because there is no interface to set or get a fractional second. The additional half second delay is because the Hardware Clock updates to the following second precisely 500 ms after setting the new time. Unfortunately, this behavior is hardware specific and in same cases another delay is required.

-D, --debug Use --verbose. The --debug option has been deprecated and may be repurposed or removed in a future release.

--directisa This option is meaningful for ISA compatible machines in the x86 and x86_64 family. For other machines, it has no effect. This option tells hwclock to use explicit I/O instructions to access the Hardware Clock. Without this option, hwclock will use the rtc device file, which it assumes to be driven by the Linux RTC device driver. As of v2.26 it will no longer automatically use directisa when the rtc driver is unavailable; this was causing an unsafe condition that could allow two processes to access the Hardware Clock at the same time. Direct hardware access from userspace should only be used for testing, troubleshooting, and as a last resort when all other methods fail. See the --rtc option.

--epoch=year This option is required when using the --setepoch function. The minimum year value is 1900. The maximum is system dependent (ULONG_MAX - 1).

-f, --rtc=filename Override hwclock's default rtc device file name. Otherwise it will use the first one found in this order: /dev/rtc0, /dev/rtc, /dev/misc/rtc. For IA-64: /dev/efirtc /dev/misc/efirtc

-l, --localtime; -u, --utc Indicate which timescale the Hardware Clock is set to.

The Hardware Clock may be configured to use either the UTC or the local timescale, but nothing in the clock itself says which alternative is being used. The --localtime or --utc options give this information to the hwclock command. If you specify the wrong one (or specify neither and take a wrong default), both setting and reading the Hardware Clock will be incorrect.

If you specify neither --utc nor --localtime then the one last given with a set function (--set, --systohc, or --adjust), as recorded in /etc/adjtime, will be used. If the adjtime file doesn't exist, the default is UTC.

Note: daylight saving time changes may be inconsistent when the Hardware Clock is kept in local time. See the discussion below, under LOCAL vs UTC.

--noadjfile Disable 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.

--test Do not actually change anything on the system, that is, the Clocks or /etc/adjtime (--verbose is implicit with this option).

--update-drift Update the Hardware Clock's drift factor in /etc/adjtime. It can only be used with --set or --systohc.

A minimum four hour period between settings is required. This is to avoid invalid calculations. The longer the period, the more precise the resulting drift factor will be.

This option was added in v2.26, because it is typical for systems to call hwclock --systohc at shutdown; with the old behavior this would automatically (re)calculate the drift factor which caused several problems:

• When using NTP with an '11 minute mode' kernel the drift factor would be clobbered to near zero.

• It would not allow the use of 'cold' drift correction. With most configurations using 'cold' drift will yield favorable results. Cold, means when the machine is turned off which can have a significant impact on the drift factor.

• (Re)calculating drift factor on every shutdown delivers suboptimal results. For example, if ephemeral conditions cause the machine to be abnormally hot the drift factor calculation would be out of range.

• Significantly increased system shutdown times (as of v2.31 when not using --update-drift the RTC is not read).

Having hwclock calculate the drift factor is a good starting point, but for optimal results it will likely need to be adjusted by directly editing the /etc/adjtime file. For most configurations once a machine's optimal drift factor is crafted it should not need to be changed. Therefore, the old behavior to automatically (re)calculate drift was changed and now requires this option to be used. See the discussion below, under The Adjust Function.

This option requires reading the Hardware Clock before setting it. If it cannot be read, then this option will cause the set functions to fail. This can happen, for example, if the Hardware Clock is corrupted by a power failure. In that case, the clock must first be set without this option. Despite it not working, the resulting drift correction factor would be invalid anyway.

-v, --verbose Display more details about what hwclock is doing internally.