Anacron 启动但不运行 cron.daily

Anacron 启动但不运行 cron.daily
$ grep anacron /var/log/syslog
Feb 20 19:05:11 jesus-Custom-PC anacron[1410]: Anacron 2.3 started on 2016-02-20
Feb 20 19:05:11 jesus-Custom-PC anacron[1410]: Normal exit (0 jobs run)
Feb 20 19:05:13 jesus-Custom-PC anacron[2022]: Anacron 2.3 started on 2016-02-20
Feb 20 19:05:13 jesus-Custom-PC anacron[2022]: Normal exit (0 jobs run)

正如您所看到的,anacron 启动了,但并没有运行cron.daily,也没有告知它将延迟运行。

我已尝试这样做$ grep 19:05 /var/log/syslog以搜索错误,但 anacron 启动和退出之间没有错误。

Cron日志:

$ grep CRON /var/log/syslog
Feb 20 19:05:11 jesus-Custom-PC cron[1263]: (CRON) INFO (pidfile fd = 3)
Feb 20 19:05:11 jesus-Custom-PC cron[1417]: (CRON) STARTUP (fork ok)
Feb 20 19:05:11 jesus-Custom-PC cron[1417]: (CRON) INFO (Running @reboot jobs)
Feb 20 19:09:01 jesus-Custom-PC CRON[3390]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Feb 20 19:17:01 jesus-Custom-PC CRON[3945]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 20 19:20:01 jesus-Custom-PC CRON[3965]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Feb 20 19:39:01 jesus-Custom-PC CRON[4205]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Feb 20 19:40:01 jesus-Custom-PC CRON[4219]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Feb 20 20:00:01 jesus-Custom-PC CRON[4569]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Feb 20 20:09:01 jesus-Custom-PC CRON[4770]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Feb 20 20:17:01 jesus-Custom-PC CRON[4843]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 20 20:20:01 jesus-Custom-PC CRON[4939]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Feb 20 20:39:01 jesus-Custom-PC CRON[5407]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Feb 20 20:40:01 jesus-Custom-PC CRON[5470]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)

Anacrontab:

$ cat /etc/anacrontab 
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

计划表:

$ cat /etc/crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
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 )

强制运行 anacron 脚本可以正确执行:

$ sudo anacron -fnd
Anacron 2.3 started on 2016-02-20
Will run job `cron.daily'
Will run job `cron.weekly'
Will run job `cron.monthly'
Jobs will be executed sequentially
Job `cron.daily' started
...

答案1

我不知道为什么它没有执行作业,但今天早上我看到了这一点:

Feb 21 11:55:22 jesus-Custom-PC anacron[1398]: Job `cron.daily' terminated
Feb 21 11:55:22 jesus-Custom-PC anacron[1398]: Job `cron.weekly' started
Feb 21 11:55:22 jesus-Custom-PC anacron[5148]: Updated timestamp for job `cron.weekly' to 2016-02-21
Feb 21 11:55:24 jesus-Custom-PC anacron[1398]: Job `cron.weekly' terminated
Feb 21 11:55:24 jesus-Custom-PC anacron[1398]: Normal exit (2 jobs run)

所以我认为它是有效的。

相关内容