如果启用 anacron,谁在 /etc/cron.hourly 中运行脚本?

whi*_*edb 3 scripts cron anacron

我读过,如果anacron启用,cron则不会在 cron.weekly/hourly/daily/hourly 中运行脚本,因为不会运行它们两次。所以要anacron对那个文件夹负责。

但是anacron不适用于每小时脚本。那么,谁运行 /etc/cron.hourly?

对不起,如果这是一个初学者的问题。

mur*_*uru 6

如果您查看/etc/crontab,您会看到:

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   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 )
Run Code Online (Sandbox Code Playgroud)

然后检查状态cron

$ service cron status
cron start/running, process 1041
Run Code Online (Sandbox Code Playgroud)

anacron本身不作为服务运行/守护,但作为一个cron作业:/etc/cron.d/anacron。因此,cron正在运行,检查是否anacron存在对每日,每周和每月的任务,而不是为每小时任务。cron运行每小时任务。

  • @redraw不是偏离主题:)请参阅http://askubuntu.com/questions/149490/what-is-the-story-behind-the-default-times-set-in-etc-crontab (2认同)