gpt4 book ai didi

unix - 使用 ntpd 可能会搞乱 cron 作业吗?

转载 作者:行者123 更新时间:2023-12-04 13:57:36 24 4
gpt4 key购买 nike

我的系统有很多时间漂移,几周后它可以提前大约 5 分钟。

为了解决这个问题,我安装了 ntp,它可以帮助修复偏差,当然偶尔也会将时间同步到 ntp 服务器。

假设我有一个 cron 任务,比如备份文件。是否可能出现以下情况?

02:00:00 - Cron starts a job
02:00:03 - Ntpd syncs time back 5 seconds to 01:59:58
02:00:00 - 2:00 gets repeated and cron job runs twice

如果 cron 作业复制大文件,第二次运行可能会尝试覆盖第一个作业未完成写入的文件。

谢谢!

最佳答案

这是 cron(8) 手册页的内容(这是针对 Vixie cron 的;其他实现的行为可能不同):

Special considerations exist when the clock is changed by less than 3 hours, for example at the beginning and end of day‐ light savings time. If the time has moved forwards, those jobs which would have run in the time that was skipped will be run soon after the change. Conversely, if the time has moved backwards by less than 3 hours, those jobs that fall into the repeated time will not be re-run.

Only jobs that run at a particular time (not specified as @hourly, nor with '*' in the hour or minute specifier) are affected. Jobs which are specified with wildcards are run based on the new time immediately.

Clock changes of more than 3 hours are considered to be corrections to the clock, and the new time is used immediately.

关于unix - 使用 ntpd 可能会搞乱 cron 作业吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8682483/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com