#安装ntpdate
yum -y install ntpdate
#创建crontab任务
crontab -e
#添加定时任务
*/5 * * * * /usr/sbin/ntpdate time1.aliyun.com >> /tmp/autontpdate 2>&1
*/20 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1
#重启crontab
service crond reload
systemctl reload crond
设置显示北京时间
[root@localhost ~]# mv /etc/localtime /etc/localtime.bak
[root@localhost ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime