The Linux system has two time, one is the system time, the other is the CMOS time.
Need to put two time to tune!
Method One: Modify the system time
(1). Log in as root and adjust the system time with the date command
Date-s "2017/11/10 10:20:00" Change the system time to November 10, 17 10:20
This modification fails after the system restarts, so in order to make this time permanent, the modified time needs to be written to the CMOS.
(2) then perform hwclock-w to synchronize the system time to CMOS time
Time to look at CMOS:
#hwclock/clock–r
Writes the current system time to the CMOS
#hwclock/clock–w
Method Two: Modify hardware time
(1). Log in as root and tune CMOS time with hwclock/clock--set--date command
Hwclock/clock--set--date== "10:20:00 2017-11-10" to change CMOS time to November 10, 2017 10:20 0 seconds)
(2) then perform hwclock-s to synchronize CMOS time to system time
0 0 * * hwclock-s can be added under the root user's crontab-e
Keep syncing every day
Common formatting:
A, Hwclock/clock--set--date= "month/day/year: minutes: Seconds"
#hwclock/clock--set--date= "09/17/2003 09:54:00"
b, or hwclock--set--date hh:mm:ss command
Hwclock/clock--set--date 09:54:00
Hwclock: Hardware Clock
-W: Synchronizing system time to hardware time
-S: Synchronizing hardware time to System time
In Linux system, CMOS time is more accurate, but system time error is large (especially virtual machine).
Date-r/etc/passwd//View the last modified time of the file
This article is from "Operation and maintenance record Mei Ling" blog, please be sure to keep this source http://meiling.blog.51cto.com/6220221/1980557
Time modification under Linux