采用crontab的方法如下:
#检查dns是否设置
cat /etc/resolv.conf
#如果未设置,在文件尾部添加dns,示例
nameserver 192.168.0.1
#设置每天1点0分执行
vi /etc/crontab
0 1 * * * ntpdate ntpdate us.pool.ntp.org > /dev/null 2>&1
如果提示:ntpdate: command not found,说明ntpdate没有安装,可以在线安装:yum install ntp