linux crontab+ntpdate同步时间

发现服务器时间错了,设置下定时任务。

crontab -u root -e
# 编辑内容 加入以下语句 每十分钟同步一次时间
*/10 * * * * /usr/sbin/ntpdate ntp1.aliyun.com

第二天发现不起作用。
手动设置下,执行一下语句。

/usr/sbin/ntpdate ntp1.aliyun.com

发现报错如下:

21 Sep 14:39:09 ntpdate[24744]: the NTP socket is in use, exiting

解决方法:停止ntpd

service ntpd stop

crontab 定时任务还需要观察几天

参考:解决the NTP socket is in use, exiting问题
参考:Linux crontab命令详解

发布了18 篇原创文章 · 获赞 6 · 访问量 8534

猜你喜欢

转载自blog.csdn.net/m0_37827628/article/details/105380235