anacron 搞砸了我的 crontab?

anacron 搞砸了我的 crontab?

我的系统是 CentOS 6.3,我注意到我的 /etc/cron.daily 不是在凌晨 4:01 执行的,而是在随机的时间。我搜索了一下,发现是“anacron”搞砸了我的 crontab。例如,这些是来自 /var/log/cron 的日志文件的一部分:

Oct  1 04:01:01 xfiles anacron[7350]: Anacron started on 2012-10-01
Oct  1 04:01:01 xfiles anacron[7350]: Will run job `cron.daily' in 18 min.
Oct  1 04:01:01 xfiles anacron[7350]: Jobs will be executed sequentially
Oct  1 04:01:01 xfiles run-parts(/etc/cron.hourly)[7352]: finished 0anacron
Oct  1 04:19:01 xfiles anacron[7350]: Job `cron.daily' started

Oct  2 03:01:01 xfiles anacron[8810]: Anacron started on 2012-10-02
Oct  2 03:01:01 xfiles anacron[8810]: Will run job `cron.daily' in 36 min.
Oct  2 03:01:01 xfiles anacron[8810]: Jobs will be executed sequentially
Oct  2 03:01:01 xfiles run-parts(/etc/cron.hourly)[8812]: finished 0anacron
Oct  2 03:37:01 xfiles run-parts(/etc/cron.daily)[10133]: starting 00webalizer

Oct  3 03:01:01 xfiles anacron[14989]: Will run job `cron.daily' in 30 min.
Oct  3 03:01:01 xfiles anacron[14989]: Jobs will be executed sequentially
Oct  3 03:01:01 xfiles run-parts(/etc/cron.hourly)[14991]: finished 0anacron
Oct  3 03:31:01 xfiles anacron[14989]: Job `cron.daily' started
Oct  3 03:31:01 xfiles run-parts(/etc/cron.daily)[16301]: starting 00webalizer

Oct  4 03:01:01 xfiles anacron[16357]: Will run job `cron.daily' in 12 min.
Oct  4 03:01:01 xfiles anacron[16357]: Jobs will be executed sequentially
Oct  4 03:01:01 xfiles run-parts(/etc/cron.hourly)[16359]: finished 0anacron
Oct  4 03:13:01 xfiles anacron[16357]: Job `cron.daily' started
Oct  4 03:13:01 xfiles run-parts(/etc/cron.daily)[16692]: starting 00webalizer    

Oct  5 03:01:01 xfiles anacron[19413]: Will run job `cron.daily' in 29 min.
Oct  5 03:01:01 xfiles anacron[19413]: Jobs will be executed sequentially
Oct  5 03:01:01 xfiles run-parts(/etc/cron.hourly)[19415]: finished 0anacron
Oct  5 03:30:01 xfiles anacron[19413]: Job `cron.daily' started
Oct  5 03:30:01 xfiles run-parts(/etc/cron.daily)[20086]: starting 00webalizer

可以看到 /etc/cron.daily 就是不能在固定的时间启动,有时候是 3:30 ,有时候是 3:13 ,有时候是 3:37 ,或者 4:19 ......

在以前的 CentOS (5.x) 中,/etc/cron.daily 正确地在凌晨 4:01 启动。但我就是搞不懂 CentOS6 的 anacron 怎么搞砸了 cron 计划。如何让系统表现得像 CentOS 5.x 一样,只在固定时间(例如 4:01)启动 /etc/cron.daily?

谢谢。

(这是一个 24/7 服务器,没有关机问题)

答案1

如果RANDOM_DELAY在您的中设置了/etc/anacrontab,那么这是预期的行为。

逐字复制自手册页 anacrontab(5)

如果设置了 RANDOM_DELAY 环境变量,则会将 0 到 RANDOM_DELAY 分钟之间的随机值添加到作业的启动延迟中。例如,将 RANDOM_DELAY 设置为 12 会将 0 到 12 分钟之间的随机值添加到用户定义的延迟中。

这也许可以解释您的症状。

答案2

根据说明安装 cronie-noanacron 这里一切就绪。

相关内容