linux crontab+ntpdate同步时间

Winola ·
更新时间:2024-09-20
· 746 次阅读

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

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命令详解


作者:¥三石



Linux ntpdate crontab

需要 登录 后方可回复, 如果你还没有账号请 注册新账号