安装ntp工具:
yum -y install ntp ntpdate
设置时间同步
ntpdate cn.ntp.org.cn
将系统时间写入硬件时间
hwclock --systohc
配置ntp同步阿里云时间服务器
vi /etc/ntp.conf
server ntp1.aliyun.com
server ntp2.aliyun.com
server ntp3.aliyun.com
#server 0.centos.pool.ntp.org iburst
启动ntp服务器
service ntpd start
配置计划任务,每5分钟同步一次
$ crontab -e
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com
常用ntpserver:
202.120.2.101 上海交通大学
cn.ntp.org.cn
ntp1.aliyun.com