Time to synchronize the server for various reasons after the installation of CentOS 7 or the device time zone.
In CentOS 7 there is a command timedatectl can help us to modify the time zone of the server.
First we can use the TIMEDATECTL command to view the current time zone settings in the server:
Local time:wed 2015-07-22 16:48:14 CST
Universal time:wed 2015-07-22 08:48:14 UTC
Timezone:asia/shanghai (CST, +0800)
NTP Enabled:yes
NTP Synchronized:yes
RTC in local Tz:yes
DST active:n/a
You can see all the settings in the current server such as time, timezone, NTP, etc.
We can use the command "Timedatectl list-timezones" to view all time zones
After viewing the time zone we can use the command "Timedatectl Set-timezone time zone"
For example, we need to set up a time zone in Shanghai: "Timedatectl set-timezone Asia/shanghai"
After setting the time zone, you can also set the NTP server to open and close
Turn on NTP: "Timedatectl set-ntp yes"
Turn off NTP: "Timedatectl set-ntp No"
Of course, the TIMEDATECTL command can also set the date and time
Set Date: "Timedatectl set-time yyyy-mm-dd"
Set time: "Timedatectl set-time HH:MM:SS"
CentOS 7 Time zone settings