In the new CENTOS7, the instruction on time adds a unified command Timedatactl, in addition to keeping the date, Hwclock, and other commands commonly used in previous versions. Below is a summary of the following in conjunction with its usage.
View TIMEDATECTL instruction Usage Help
The code is as follows |
Copy Code |
[Root@361way ~]# Timedatectl--help Timedatectl [OPTIONS ...] COMMAND ... Query or change the system time and date settings. -H--help Show this Help --version Show Package version --adjust-system-clock Adjust system clock When changing local RTC mode --no-pager don't pipe output into a pager -P--privileged acquire privileges before execution --no-ask-password don't prompt for password -H--host=[user@]host Operate on remote host Commands: Status Show Current time settings Set-time Time Set system time Set-timezone ZONE Set System timezone List-timezones Show known TimeZones SET-LOCAL-RTC Boolean Control whether RTC SET-NTP BOOL Control whether NTP is enabled |
More detailed help information can also be viewed through the man timedatectl.
View current settings, direct input timedatectl equivalent to TIMEDATECTL status
code is as follows |
copy code |
[root@361way ~] # timedatectl local time:wed 2014-09-24 21:19:26 CST Universal time:wed 20 14-09-24 13:19:26 UTC RTC time:wed 2014-09-24 13:19:26 Timezone:asia/shanghai (CST, +0800) NTP Enabled:yes NTP synchronized:yes  RTC in local tz:no DST active:n/a |
Set Date
Timedatectl set-time yyyy-mm-dd
Set current time
Timedatectl set-time HH:MM:SS
Default, when the system is in use UTC , you can turn UTC time on and off by using the following command:
Timedatectl SET-LOCAL-RTC Boolean
Substituting Boolean for Yes to use local time, replace with no to indicate UTC time
Note: This Boolean value can also be used to set the time zone with true, Flase
:
To view all time zones:
Timedatectl list-timezones
To set the time zone under the command:
Timedatectl set-timezone time_zone
Remote NTP server synchronization
Timedatectl can also set whether to turn on NTP options
Timedatectl set-ntp Boolean
The Boolean here is yes or no
In addition to the above usage, TIMEDATECTL also supports the time setting of a remote host through the-H parameter.