Linux hwclock command
The Linux hwclock command is used to display and set the hardware clock.
In Linux, there are two types of clocks: the hardware clock and the system clock. The hardware clock refers to the clock device on the motherboard, which is usually the clock that can be set in the BIOS screen. The system clock refers to the clock in the kernel. When Linux starts, the system clock reads the settings of the hardware clock, and then the system clock operates independently. All Linux-related commands and functions read the settings of the system clock.
Syntax
hwclock [--adjust][--debug][--directisa][--hctosys][--show][--systohc][--test] [--utc][--version][--set --date=<日期与时间>]
Parameters:
- --adjust Every time hwclock changes the hardware clock, it records it in the /etc/adjtime file. Using the --adjust parameter allows hwclock to estimate the deviation of the hardware clock based on previous records and use it to correct the current hardware clock.
- --debug Displays detailed information when hwclock is executed.
- --directisa By default, hwclock accesses the hardware clock from the /dev/rtc device. If it cannot be accessed, this parameter can be used to directly access the hardware clock using I/O instructions.
- --hctosys Adjusts the system clock to be consistent with the current hardware clock.
- --set --date=<date and time> Sets the hardware clock.
- --show Displays the time and date of the hardware clock.
- --systohc Adjusts the hardware clock to be consistent with the current system clock.
- --test Only tests the program without actually changing the hardware clock.
- --utc If you want to use Greenwich Mean Time, add this parameter, and hwclock will perform the conversion.
- --version Displays version information.
Examples
Display current time
# hwclock 2010年05月27日 星期四 18时04分31秒 -0.704214 seconds
View version information
# hwclock -v hwclock from util-linux-2.12aOther Extensions
Linux Command Encyclopedia