Linux system time and hardware time settings, linux hardware
1. Introduction
In Linux, there are two types of Clock: hardware clock and system clock. The hardware clock refers to the clock device on the motherboard, that is, the clock that can usually be set on the BIOS screen. At this time, the battery power on the motherboard is maintained. If the battery on the motherboard is exhausted, the battery will be restored to the factory settings if the power is down. The system clock is the clock in the kernel. All Linux-related commands and functions are read system clock settings. Because there are two different clock types, there will be differences between them. When Linux is started, the system clock reads the hardware clock settings, and then the system clock runs independently.
For system time, we can use the date command to view:
Unicom @ ubuntu :~ $ Date
Wed Apr 15 15:52:23 CST 2015
Run the hwclock command to view the hardware time.
Unicom @ ubuntu :~ $ Sudo hwclock-show // hardware time requires root permission
[Sudo] password for unicom:
Wed Apr 15 16:13:42 2015-0.844670 seconds
2. Time settings
The time set by the date command does not change the system's hardware time. After the system is restarted, the hardware time will still be loaded, which is also a problem that often causes the date setting time to fail.
The correct method is to set the system time, and then execute it to synchronize time to the hardware clock. Of course, you can also directly set the hardware clock.
Date sets the system clock.
# Date -- set "04/15/15" (month/day/year hour: minute: second)
Synchronize the system time to the hardware clock:
# sudo hwclock --systohc
Or# sudo hwclock -w
Directly set the hardware time:
# Sudo hwclock -- set -- date = "04/15/15" (month/day/year hour: minute: second)
Common command parameters for hardware clock
Command Parameters |
Description |
-R,-show |
Read hardware clock and print result) |
-S,-hctosys |
Synchronize the hardware clock to the system clock (set the system time from the hardware clock) |
-W,-systohc |
Synchronize the system clock to the hardware clock (set the hardware clock to the current system time) |