centos 6.5 时间网络同步

  • 安装 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

猜你喜欢

转载自blog.csdn.net/yld10/article/details/80337027