cron.daily not running at the time it should?
Posted
by
Mariano Martinez Peck
on Server Fault
See other posts from Server Fault
or by Mariano Martinez Peck
Published on 2014-08-23T16:18:05Z
Indexed on
2014/08/23
16:22 UTC
Read the original article
Hit count: 522
My /etc/cron.daily
scripts seem to be executing far later from what I understand they should. I am in Ubuntu and anacron is installed.
If I do a sudo cat /var/log/syslog | grep cron
I get something like:
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
As you can see, at 3:25 it tried to do something. But the cron.daily
execution started really at 7:35.
My /etc/crontab
is:
# /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
# m h 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 )
#
From what I understand, daily scripts are indeed for 3:25.
My /etc/anacrontab
is:
# /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
So...does someone know why my cron started to do something at 3:25 but then really start the jobs at 7:35?
Also..as you can see in the log, hourly jobs are being executed at correct time: hour and 17 minutes, which is exactly what I have in /etc/crontab
Finally, from the logs, it seems my daily jobs are being actually run by anacron
rather than cron
? So cron
finds nothing to run (at 3:25) and then anacron
runs the jobs at 7:35? If true, how can I fix this?
Thanks in advance,
© Server Fault or respective owner