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

 

posted @ 2020-09-27 14:38  石铭  阅读(471)  评论(0编辑  收藏  举报