1

Sumary

I have a similar problem with cron.daily jobs not running, but the solutions there do not apply to me.

I have setup a script that should run daily through cron.daily. I placed my script in the /etc/cron.daily. When the computer is on all night, the script executes normally. However, from my understanding of anacron, if I turn off the computer and turn it on (even after the time the cron.daily runs normally), anacron should run the scripts that didn't run in the standard time. But, for some reason, anacron is not triggering everyday, and it works on some days and in others it doesn't.

Details

From the community documentation it seems that anacron should be running daily on startup

So it appears anacron is run on every startup, wake up, plug-in, and at 7:30 AM every day. Looking at the respective Changelogs and package databases, it looks like this setup is directly from Debian, and hasn't been changed since at least 2009.

but it isn't.

I tested by switching the laptop on after the time of the anacron schedule, 7:30 AM, but it is not working. At first, I thought it was skipping days but I don't know where to search for that configuration, as I didn't change its behavior.

If you need any logs let me know, I can provide them.

Logs

/etc/log/syslog

$ cat /var/log/syslog | grep cron
Mar 10 09:40:36 computer anacron[798]: Job `cron.daily' terminated
Mar 10 09:40:36 computer anacron[798]: Normal exit (1 job run)
Mar 10 10:17:01 computer CRON[26842]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 11:17:01 computer CRON[27296]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 12:17:01 computer CRON[28337]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 13:14:01 computer CRON[28761]: (root) CMD (   test -x /etc/cron.daily/popularity-contest && /etc/cron.daily/popularity-contest --crond)
Mar 10 13:17:02 computer CRON[28779]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 14:00:48 computer systemd[1]: Started Run anacron jobs at resume.
Mar 10 14:17:01 computer CRON[30881]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 15:17:01 computer CRON[31557]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 17:19:19 computer systemd[1]: Started Run anacron jobs at resume.
Mar 10 18:17:01 computer CRON[2100]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 19:17:01 computer CRON[2745]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 10 20:17:01 computer CRON[3475]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 13 09:33:19 computer cron[918]: (CRON) INFO (pidfile fd = 3)
Mar 13 09:33:19 computer cron[918]: (CRON) INFO (Running @reboot jobs)
Mar 13 10:17:01 computer CRON[9045]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 13 11:17:01 computer CRON[13534]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 13 12:17:01 computer CRON[20925]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 13 13:14:01 computer CRON[21354]: (root) CMD (   test -x /etc/cron.daily/popularity-contest && /etc/cron.daily/popularity-contest --crond)
Mar 13 13:17:01 computer CRON[21377]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 13 14:17:01 computer CRON[22770]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 13 15:17:01 computer CRON[24406]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

Non-filtered log for the first hours of the system on 10/03 and 13/03.

  • Please edit your question to show your /var/log/syslog during a time when your script runs successfully, and a time when it doesn't run. – user535733 Mar 13 '17 at 18:33
  • I dumped the syslog from 10 when it ran, and 13 when it didn't. I filter it through cron let me know if you need the whole thing or another filter. – adn Mar 13 '17 at 18:39
  • No filter - we want to see the trigger (like cron.hourly) and the job running, then the same trigger and the job not running. There's usually a helpful error message in sylog when a job fails...or we'll see that the trigger didn't run. – user535733 Mar 13 '17 at 18:44
  • Added the logs. I put the first hours as there is too much data for pastebin to handle. Let me know if you need other hours I can add them. – adn Mar 13 '17 at 19:14
  • 1
    not sure this is still relevant. came across this while configuring anacron myself. looking at my (default) /etc/init.d/anacron script it only starts anacron when -not- running on battery power (assuming it is able to determine this). so that then triggers the question if you were running on battery power on days where anacron did not execute :)? – Kees Beets Jul 13 '17 at 11:27
0

I had noticed that anacron wasn't running the daily jobs on my good laptop, yet ran reliably on two ancient ones. After several months of noodling around I stumbled across the answer. This applies to laptops only.

There's a file in /etc/cron.daily called 'app-compat'. Near the end of that file are these lines:

(#) ensure we don't do this on battery
check_power || exit 0

Note: I had to put parens around the hash sign or it made the line appear bold on this page. In the file it's just a hash sign, the usual comment sign.

I commented out the check_power line to permit cron.daily to run while on battery.

This newer laptop has a good battery and I almost never use it while plugged into the charger. The other two old ones are always plugged in since their batteries are in poor shape. So cron.daily ran on the old machines but not on the new one.

    Don Karon

Addendum: I may have to eat some crow here. It appears that, even with the removal of the don't-do-it-while-on-battery command cron.daily is still not executing reliably on this laptop. The search resumes.

|improve this answer|||||
  • Battery power was already mentioned in comments and OP left off saying that would be checked out but no update came after that. – WinEunuuchs2Unix Oct 17 '19 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.