In the CentOS 6 version, the time setting has the date, Hwclock command, starting with CentOS 7, using a new command timedatectl.
I. Basic CONCEPTS
1.1 GMT, UTC, CST, DST time
(1) UTC
The whole earth is divided into 24 time zones, each of which has its own local time. In international radiocommunication situations, for the sake of unification, a uniform time is used, called Universal Coordinated Time (UTC, universal times coordinated).
(2) GMT
Greenwich Mean Time (Greenwich Mean times) refers to the standard time of the Royal Greenwich Observatory, located in the suburbs of London, England, as Meridian is defined through the meridians there. (UTC is basically the same as GMT time, no distinction is made in this article)
(3) CST
China Standard Time (Standard times)
The code is as follows:
GMT + 8 = UTC + 8 = CST
(4) DST
Daylight saving time (daylight saving times) refers to the early days when the sun rises in summer, the clock is set to one hour faster to use early daylight. (not used in China)
1.2 Hardware clock and system clock
(1) Hardware clock
RTC (real-time Clock) or CMOS clock, generally on the motherboard by battery power, the server will continue to run after power. The time zone and daylight saving time settings cannot be saved by saving only datetime values.
(2) System clock
Typically, the RTC time is replicated when the server is started, and then run independently, saving time, timezone, and daylight saving times settings.
Second, timedatectl order
2.1 Read Time
The code is as follows:
Timedatectl//equivalent to TIMEDATECTL status
2.2 Set time
The code is as follows:
Timedatectl set-time "Yyyy-mm-dd HH:MM:SS"
2.3 List all time zones
The code is as follows:
Timedatectl List-timezones
2.4 Setting the time zone
The code is as follows:
Timedatectl Set-timezone Asia/shanghai
2.5 is NTP server synchronized
The code is as follows:
Timedatectl SET-NTP Yes//yes or no
2.6 Adjust the hardware clock to match the local clock
The code is as follows:
Timedatectl SET-LOCAL-RTC 1
Hwclock--SYSTOHC--localtime//Consistent with the above command
Note that the hardware clock uses UTC time by default because the hardware clock does not save time zones and daylight saving time adjustments, and it is not possible to read the exact standard times from the hardware clock after the modification is recommended. The following warning appears when the system is modified.
2.6 Hardware time is set to UTC:
The code is as follows:
Timedatectl SET-LOCAL-RTC 1
Hwclock--SYSTOHC--UTC//Consistent with the above command