This article was reproduced from: http://blog.csdn.net/little_walt/article/details/52880840
The Linux system consists of two times: System time and RTC time.
System time: Is the timer of the main chip to maintain the time, under normal circumstances will choose the highest precision on the chip timer as the timing of the system time benchmark, in order to avoid a long time after the system run a large time offset. Features are not saved after power-down.
RTC Time: Refers to the time that is maintained within the RTC chip included in the system. The RTC Chip has a dual power supply mechanism for battery + system power, which is powered by the system when the system is in normal operation and powered by the battery after the system has lost power. As a result, the RTC time is still running after the system is powered down.
The RTC driver is detected and mounted in the boot process every time the Linux system is booted, and the time is automatically read from the RTC chip and set to the system time after mounting. Thereafter, if there is no explicit command to control the RTC's read and write operations, the system will no longer get or synchronize the set-up time from the RTC.
The date and time commands in the Linux command are used to set the system times, while the Hwclock command is used to set and read and write RTC time.
Read system time: Date
Set the system time: Date-s 011209512012.00 Set the system time to January 12, 2012 9:51 00 seconds
Note: The date-s command setup time only affects the system time, does not set the RTC time, and if you need to set the current system time synchronization to RTC, additional calls to the Hwclock command are required.
The Hwclock command uses:
Hwclock-r Read and print the current RTC time
Hwclock-s Read the RTC time and set it to the system time
Hwclock-w to set the current system time to RTC
So the complete set of RTC time can execute the following command:
Date-s 011209512012.00
Hwclock-w
In addition, in order to automatically perform RTC time synchronization to System time at startup, you can
Hwclock-s
Added to the rc.local or RCS file.
Read and write analysis of RTC time under Linux "turn"