- 安装 ntpdate
sudo yum -y install ntp ntpdate
- 修改为上海时区
sudo vim /etc/sysconfig/clock
ZONE = "Asia/Shanghai"
UTC = false
ARC = false
- 使文件修改生效
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 到这一步之后时间应该恢复正常了
- 设置时间同步
sudo ntpdate cn.pool.ntp.org
- 系统时间写入硬件时间
sudo hwclock --systohc
- 强制系统时间写入 CMOS 中防止重启失效
sudo hwclock -w
- 设置定时任务同步时间
sudo crontab -e
00 12 * * * /usr/sbin/ntpdate cn.pool.ntp.org
- OK 啦!
感谢:
https://blog.csdn.net/u011391839/article/details/62892020
https://blog.csdn.net/liushunqiu/article/details/52386674
本文详细介绍了如何在CentOS系统上进行时间同步配置,包括安装ntpdate、设置上海时区、通过ntpdate命令同步时间、将系统时间写入硬件时间等步骤,并提供了设置定时任务以确保时间持续同步的方法。

1433

被折叠的 条评论
为什么被折叠?



