Skip to content

centos7同步时间

Published:

设置时区

# 查看时区
timedatectl status|grep 'Time zone'

# 设置硬件时钟调整为与本地时钟一致
timedatectl set-local-rtc 1

# 设置时区为上海
timedatectl set-timezone Asia/Shanghai

使用ntpdate同步时间

# 安装ntpdate
yum -y install ntpdate

# 执行同步
ntpdate -u pool.ntp.org

# 查看时间是否已经同步正确
date

# 其他ntp server
# 中国
cn.ntp.org.cn
# 中国香港
hk.ntp.org.cn
# 美国
us.ntp.org.cn