cron.daily在当时不应该运行?

我的/etc/cron.daily脚本似乎执行/etc/cron.daily我所理解的要晚得多。 我在Ubuntu和anacron安装。

如果我做一个sudo cat /var/log/syslog | grep cron sudo cat /var/log/syslog | grep cron我得到像这样的东西:

 Aug 23 01:17:01 mymachine CRON[25171]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 02:17:01 mymachine CRON[25588]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 03:17:01 mymachine CRON[26026]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 03:25:01 mymachine CRON[30320]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )) Aug 23 04:17:01 mymachine CRON[26363]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 05:17:01 mymachine CRON[26770]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 06:17:01 mymachine CRON[27168]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 07:17:01 mymachine CRON[27547]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Aug 23 07:30:01 mymachine CRON[2249]: (root) CMD (start -q anacron || :) Aug 23 07:30:02 mymachine anacron[2252]: Anacron 2.3 started on 2014-08-23 Aug 23 07:30:02 mymachine anacron[2252]: Will run job `cron.daily' in 5 min. Aug 23 07:30:02 mymachine anacron[2252]: Jobs will be executed sequentially Aug 23 07:35:02 mymachine anacron[2252]: Job `cron.daily' started 

正如你所看到的,在3:25它试图做一些事情。 但是cron.daily执行在7:35开始。

我的/etc/crontab是:

 # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # mh dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 3 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 

据我所知,每天的脚本确实是3:25。

我的/etc/anacrontab是:

 # /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin HOME=/root LOGNAME=root # These replace cron's entries 1 5 cron.daily run-parts --report /etc/cron.daily 7 10 cron.weekly run-parts --report /etc/cron.weekly @monthly 15 cron.monthly run-parts --report /etc/cron.monthly 

所以…有人知道为什么我的克朗在3:25开始做点什么,但是在7点35分才真正开始工作?

另外,如你可以在日志中看到的,每小时工作正在正确的时间执行:小时和17分钟,这正是我在/etc/crontab

最后,从日志看来,我的日常工作似乎是由anacron而不是cron实际运行的? 所以cron找不到任何东西(3:25),然后anacron在7:35运行这个工作? 如果属实,我该如何解决这个问题?

提前致谢,

 test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 

这将运行test命令,然后只在testing命令失败时才运行( cd ...)序列。 如果安装了anacron,那么testing命令将会成功,而命令行的其余部分将不会运行。 换句话说,如果anacron没有安装,这行只执行cron.daily

同时,anacron被周期性的调用,最终基于自己的configuration文件运行cron.daily 。 看起来anacron可能不会在一天之前被调用,否则它会在早些时候运行cron.daily。

如果你想让命令从cron而不是anacron运行,你可以编辑它们各自的configuration,也许可以设置anacron在当天早些时候运行。 或者你可以完全删除anacron,如果你不想使用它。