Linux system time is sometimes not synchronized with hardware time
Linux clock is divided into system clock and real time clock (RTC. The system clock is the current Linux kernel clock, and the hardware clock is the battery-powered clock on the motherboard. This hardware clock can be set in the BIOS. When Linux is started, the hardware clock reads the system clock settings, and then the system clock runs independently of the hardware.
All commands (including functions) in Linux use the system clock settings. In Linux, the commands used for clock viewing and setting mainly include date, hwclock, and clock. Among them, clock and hwclock use similar, just use one line, but clock commands not only support x86 hardware system, but also support alpha hardware system.
1. Date
View system time
# date
set the system time
# date -- set" 07/07/06 "(month/day/year hour: minute: Second)
2. hwclock/clock
View hardware time
# hwclock -- show
or # clock -- show
set hardware time
# hwclock -- set -- date =" 07/07/06 "(month/day/year hour: minute: second)
or # clock -- set -- date =" 07/07/06 "(month/day/year hour: minute: Second)
3. Hardware time and System Time Synchronization
As mentioned earlier, when the system is restarted, the hardware time reads the system time for synchronization. However, if the system time is not restarted, you need to use the hwclock or clock command to synchronize data.
Hardware clock and system clock synchronization: # hwclock -- hctosys (HC indicates hardware time, sys indicates system time) or # clock -- hctosys
System clock and hardware clock synchronization: # hwclock -- systohc or # clock -- systohc
Technorati: Linux