CentOS 7 修改时区、校准时间

在CentOS 7中设置时区并校准时间

设置时区

依次使用下面命令来设置时区

1
2
timedatectl status|grep 'Time zone'  #查看当前时区
timedatectl set-timezone Asia/Shanghai #将时区设置为上海

校准时钟

依次使用下面命令来校准时钟

1
2
3
yum -y install ntpdate  #安装ntpdate,在线校准时钟
ntpdate -u pool.ntp.org #同步时钟
date #查看当前时间

附常用ntp地址:

1
2
3
4
5
6
#中国
cn.ntp.org.cn
#中国香港
hk.ntp.org.cn
#美国
us.ntp.org.cn