Centos7更新时间
1、安装ntpdate工具
yum -y install ntp ntpdate
2、执行命令(同步系统时间和网络时间)
ntpdate 0.asia.pool.ntp.org
3、将系统时间写入硬件时间
hwclock --systohc
Centos7更新时间一直不准确
我按照上面步骤执行后时间一直更新失败后,发现原来是时区的问题
1、查看当前时区
date
2、查看当前时区
date
得到结果Wed Jul 21 19:57:19 PDT 2021,PDT时区是不正确的需要修改为正确时区CST
3、修改时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ll /etc/localtime
ll /usr/share/zoneinfo/Asia/Shanghai
3、再次使用ntpdate同步时间
ntpdate 0.asia.pool.ntp.org
4、将系统时间写入硬件时间
hwclock --systohc