How to make Anacron startup reliably?











up vote
2
down vote

favorite
1












So, I'm using Anacron to be able to reliably run some scripts daily. However, this doesn't work when Anacron itself doesn't start on boot half the time. How would I get Anacron to start up reliably?



> grep 'anacron' /var/log/syslog.2
May 18 19:09:02 s-laptop anacron[2480]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 18 19:09:02 s-laptop anacron[2480]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: anacron: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: Normal exit (1 job run)
May 18 21:20:48 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 16:30:46 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 17:02:27 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 18:58:50 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 19:13:48 s-laptop systemd[1]: Started Run anacron jobs.
May 20 19:13:48 s-laptop anacron[734]: Anacron 2.3 started on 2017-05-20
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.daily' in 5 min.
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.weekly' in 10 min.
May 20 19:13:48 s-laptop anacron[734]: Jobs will be executed sequentially
May 20 19:18:51 s-laptop anacron[734]: Job `cron.daily' started
May 20 19:18:51 s-laptop anacron[2367]: Updated timestamp for job `cron.daily' to 2017-05-20
> grep 'anacron' /var/log/syslog.1
May 20 19:18:54 s-laptop anacron[734]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 20 19:23:48 s-laptop anacron[734]: Job `cron.weekly' started
May 20 19:23:48 s-laptop anacron[2606]: Updated timestamp for job `cron.weekly' to 2017-05-20
May 20 19:30:09 s-laptop anacron[734]: Job `cron.weekly' terminated
May 20 19:30:09 s-laptop anacron[734]: Normal exit (2 jobs run)
May 21 10:02:56 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 25 12:53:39 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 1 18:09:14 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 3 12:29:40 s-laptop anacron[751]: Anacron 2.3 started on 2017-06-03
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.daily' in 5 min.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.weekly' in 10 min.
Jun 3 12:29:40 s-laptop systemd[1]: Started Run anacron jobs.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.monthly' in 15 min.
Jun 3 12:29:40 s-laptop anacron[751]: Jobs will be executed sequentially
Jun 3 12:34:40 s-laptop anacron[751]: Job `cron.daily' started
Jun 3 12:34:40 s-laptop anacron[2243]: Updated timestamp for job `cron.daily' to 2017-06-03
> grep 'anacron' /var/log/syslog
Jun 3 12:34:44 s-laptop anacron[751]: Job `cron.daily' terminated (mailing output)


As can be seen in the syslog, Anacron was only started at boot on May 20th and June 3rd, despite the machine being booted May 21st and 25th and June 1st.



Additionally, today (June 3rd), I actually booted my computer at 12:11, and seeing that Anacron had not started and none of my jobs were run, I rebooted the machine at 12:29. You can see on this second boot, Anacron decided to startup. Why does it just not startup a lot of the time?










share|improve this question






















  • Anacron does not have a just-start-sometimes-at-random feature. After a couple reboots, my Anacron starts quite reliably on my test system. Can you suggest any changes I can make to my test system that would enable me to duplicate your problem?
    – user535733
    Jun 3 '17 at 15:48










  • OK, just started looking at the init scripts, and I think I see why. Anacron must not have started because I was on battery power. Looking at the cron entries for anacron, the next time anacron will be run is 7:30am. Is this correct? It seems a bit odd that something that is meant to make cron more reliable, will completely miss everything if it's not plugged in at boot and switched off at 7:30am. So, is it an acceptable solution to change that cron entry to run every hour, or will this cause any issues? Or, better yet, run anacron every time the machine is plugged in?
    – Sam Bull
    Jun 3 '17 at 18:07










  • Hang on. Anacron is NOT an always-on (daemon/service). It's a tiny little shim of a program that runs at startup/resume, checks the timestamp files to see if any cron jobs were missed, runs them if needed, and exits. Your logs seem to indicate that Anacron was running, and simply decided that the jobs didn't need to be triggered. Before going deep into debugging Anacron, compare first the scheduled vs actual times for cron.daily and cron.weekly. The answer might be as simple as moving your cron.daily schedule to earlier in the day.
    – user535733
    Jun 3 '17 at 21:34










  • There's no anacron started message, and nothing about running cron.daily for 05/21, 05/25, 06/01 or the first time I booted my computer 06/03 at 12:11. It did not run my cron.daily scripts anytime between 05/13 and 06/03. Despite my computer having been turned on a number of times and being switched on for several hours. It looks to me like the init script is responsible for running Anacron on boot, but won't run it if on battery (/etc/init.d/anacron). And the only other time I can see it getting run is at 7:30am in /etc/cron.d/anacron.
    – Sam Bull
    Jun 4 '17 at 13:43










  • I've also just tried adding a udev rule to run anacron when plugged in. This seems to work correctly, so I think this might be the correct fix.
    – Sam Bull
    Jun 4 '17 at 14:20















up vote
2
down vote

favorite
1












So, I'm using Anacron to be able to reliably run some scripts daily. However, this doesn't work when Anacron itself doesn't start on boot half the time. How would I get Anacron to start up reliably?



> grep 'anacron' /var/log/syslog.2
May 18 19:09:02 s-laptop anacron[2480]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 18 19:09:02 s-laptop anacron[2480]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: anacron: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: Normal exit (1 job run)
May 18 21:20:48 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 16:30:46 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 17:02:27 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 18:58:50 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 19:13:48 s-laptop systemd[1]: Started Run anacron jobs.
May 20 19:13:48 s-laptop anacron[734]: Anacron 2.3 started on 2017-05-20
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.daily' in 5 min.
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.weekly' in 10 min.
May 20 19:13:48 s-laptop anacron[734]: Jobs will be executed sequentially
May 20 19:18:51 s-laptop anacron[734]: Job `cron.daily' started
May 20 19:18:51 s-laptop anacron[2367]: Updated timestamp for job `cron.daily' to 2017-05-20
> grep 'anacron' /var/log/syslog.1
May 20 19:18:54 s-laptop anacron[734]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 20 19:23:48 s-laptop anacron[734]: Job `cron.weekly' started
May 20 19:23:48 s-laptop anacron[2606]: Updated timestamp for job `cron.weekly' to 2017-05-20
May 20 19:30:09 s-laptop anacron[734]: Job `cron.weekly' terminated
May 20 19:30:09 s-laptop anacron[734]: Normal exit (2 jobs run)
May 21 10:02:56 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 25 12:53:39 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 1 18:09:14 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 3 12:29:40 s-laptop anacron[751]: Anacron 2.3 started on 2017-06-03
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.daily' in 5 min.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.weekly' in 10 min.
Jun 3 12:29:40 s-laptop systemd[1]: Started Run anacron jobs.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.monthly' in 15 min.
Jun 3 12:29:40 s-laptop anacron[751]: Jobs will be executed sequentially
Jun 3 12:34:40 s-laptop anacron[751]: Job `cron.daily' started
Jun 3 12:34:40 s-laptop anacron[2243]: Updated timestamp for job `cron.daily' to 2017-06-03
> grep 'anacron' /var/log/syslog
Jun 3 12:34:44 s-laptop anacron[751]: Job `cron.daily' terminated (mailing output)


As can be seen in the syslog, Anacron was only started at boot on May 20th and June 3rd, despite the machine being booted May 21st and 25th and June 1st.



Additionally, today (June 3rd), I actually booted my computer at 12:11, and seeing that Anacron had not started and none of my jobs were run, I rebooted the machine at 12:29. You can see on this second boot, Anacron decided to startup. Why does it just not startup a lot of the time?










share|improve this question






















  • Anacron does not have a just-start-sometimes-at-random feature. After a couple reboots, my Anacron starts quite reliably on my test system. Can you suggest any changes I can make to my test system that would enable me to duplicate your problem?
    – user535733
    Jun 3 '17 at 15:48










  • OK, just started looking at the init scripts, and I think I see why. Anacron must not have started because I was on battery power. Looking at the cron entries for anacron, the next time anacron will be run is 7:30am. Is this correct? It seems a bit odd that something that is meant to make cron more reliable, will completely miss everything if it's not plugged in at boot and switched off at 7:30am. So, is it an acceptable solution to change that cron entry to run every hour, or will this cause any issues? Or, better yet, run anacron every time the machine is plugged in?
    – Sam Bull
    Jun 3 '17 at 18:07










  • Hang on. Anacron is NOT an always-on (daemon/service). It's a tiny little shim of a program that runs at startup/resume, checks the timestamp files to see if any cron jobs were missed, runs them if needed, and exits. Your logs seem to indicate that Anacron was running, and simply decided that the jobs didn't need to be triggered. Before going deep into debugging Anacron, compare first the scheduled vs actual times for cron.daily and cron.weekly. The answer might be as simple as moving your cron.daily schedule to earlier in the day.
    – user535733
    Jun 3 '17 at 21:34










  • There's no anacron started message, and nothing about running cron.daily for 05/21, 05/25, 06/01 or the first time I booted my computer 06/03 at 12:11. It did not run my cron.daily scripts anytime between 05/13 and 06/03. Despite my computer having been turned on a number of times and being switched on for several hours. It looks to me like the init script is responsible for running Anacron on boot, but won't run it if on battery (/etc/init.d/anacron). And the only other time I can see it getting run is at 7:30am in /etc/cron.d/anacron.
    – Sam Bull
    Jun 4 '17 at 13:43










  • I've also just tried adding a udev rule to run anacron when plugged in. This seems to work correctly, so I think this might be the correct fix.
    – Sam Bull
    Jun 4 '17 at 14:20













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





So, I'm using Anacron to be able to reliably run some scripts daily. However, this doesn't work when Anacron itself doesn't start on boot half the time. How would I get Anacron to start up reliably?



> grep 'anacron' /var/log/syslog.2
May 18 19:09:02 s-laptop anacron[2480]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 18 19:09:02 s-laptop anacron[2480]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: anacron: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: Normal exit (1 job run)
May 18 21:20:48 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 16:30:46 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 17:02:27 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 18:58:50 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 19:13:48 s-laptop systemd[1]: Started Run anacron jobs.
May 20 19:13:48 s-laptop anacron[734]: Anacron 2.3 started on 2017-05-20
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.daily' in 5 min.
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.weekly' in 10 min.
May 20 19:13:48 s-laptop anacron[734]: Jobs will be executed sequentially
May 20 19:18:51 s-laptop anacron[734]: Job `cron.daily' started
May 20 19:18:51 s-laptop anacron[2367]: Updated timestamp for job `cron.daily' to 2017-05-20
> grep 'anacron' /var/log/syslog.1
May 20 19:18:54 s-laptop anacron[734]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 20 19:23:48 s-laptop anacron[734]: Job `cron.weekly' started
May 20 19:23:48 s-laptop anacron[2606]: Updated timestamp for job `cron.weekly' to 2017-05-20
May 20 19:30:09 s-laptop anacron[734]: Job `cron.weekly' terminated
May 20 19:30:09 s-laptop anacron[734]: Normal exit (2 jobs run)
May 21 10:02:56 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 25 12:53:39 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 1 18:09:14 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 3 12:29:40 s-laptop anacron[751]: Anacron 2.3 started on 2017-06-03
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.daily' in 5 min.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.weekly' in 10 min.
Jun 3 12:29:40 s-laptop systemd[1]: Started Run anacron jobs.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.monthly' in 15 min.
Jun 3 12:29:40 s-laptop anacron[751]: Jobs will be executed sequentially
Jun 3 12:34:40 s-laptop anacron[751]: Job `cron.daily' started
Jun 3 12:34:40 s-laptop anacron[2243]: Updated timestamp for job `cron.daily' to 2017-06-03
> grep 'anacron' /var/log/syslog
Jun 3 12:34:44 s-laptop anacron[751]: Job `cron.daily' terminated (mailing output)


As can be seen in the syslog, Anacron was only started at boot on May 20th and June 3rd, despite the machine being booted May 21st and 25th and June 1st.



Additionally, today (June 3rd), I actually booted my computer at 12:11, and seeing that Anacron had not started and none of my jobs were run, I rebooted the machine at 12:29. You can see on this second boot, Anacron decided to startup. Why does it just not startup a lot of the time?










share|improve this question













So, I'm using Anacron to be able to reliably run some scripts daily. However, this doesn't work when Anacron itself doesn't start on boot half the time. How would I get Anacron to start up reliably?



> grep 'anacron' /var/log/syslog.2
May 18 19:09:02 s-laptop anacron[2480]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 18 19:09:02 s-laptop anacron[2480]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: anacron: Can't find sendmail at /usr/sbin/sendmail, not mailing output
May 18 19:09:02 s-laptop anacron[2480]: Normal exit (1 job run)
May 18 21:20:48 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 16:30:46 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 17:02:27 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 18:58:50 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 20 19:13:48 s-laptop systemd[1]: Started Run anacron jobs.
May 20 19:13:48 s-laptop anacron[734]: Anacron 2.3 started on 2017-05-20
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.daily' in 5 min.
May 20 19:13:48 s-laptop anacron[734]: Will run job `cron.weekly' in 10 min.
May 20 19:13:48 s-laptop anacron[734]: Jobs will be executed sequentially
May 20 19:18:51 s-laptop anacron[734]: Job `cron.daily' started
May 20 19:18:51 s-laptop anacron[2367]: Updated timestamp for job `cron.daily' to 2017-05-20
> grep 'anacron' /var/log/syslog.1
May 20 19:18:54 s-laptop anacron[734]: Job `cron.daily' terminated (exit status: 1) (mailing output)
May 20 19:23:48 s-laptop anacron[734]: Job `cron.weekly' started
May 20 19:23:48 s-laptop anacron[2606]: Updated timestamp for job `cron.weekly' to 2017-05-20
May 20 19:30:09 s-laptop anacron[734]: Job `cron.weekly' terminated
May 20 19:30:09 s-laptop anacron[734]: Normal exit (2 jobs run)
May 21 10:02:56 s-laptop systemd[1]: Started Run anacron jobs at resume.
May 25 12:53:39 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 1 18:09:14 s-laptop systemd[1]: Started Run anacron jobs at resume.
Jun 3 12:29:40 s-laptop anacron[751]: Anacron 2.3 started on 2017-06-03
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.daily' in 5 min.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.weekly' in 10 min.
Jun 3 12:29:40 s-laptop systemd[1]: Started Run anacron jobs.
Jun 3 12:29:40 s-laptop anacron[751]: Will run job `cron.monthly' in 15 min.
Jun 3 12:29:40 s-laptop anacron[751]: Jobs will be executed sequentially
Jun 3 12:34:40 s-laptop anacron[751]: Job `cron.daily' started
Jun 3 12:34:40 s-laptop anacron[2243]: Updated timestamp for job `cron.daily' to 2017-06-03
> grep 'anacron' /var/log/syslog
Jun 3 12:34:44 s-laptop anacron[751]: Job `cron.daily' terminated (mailing output)


As can be seen in the syslog, Anacron was only started at boot on May 20th and June 3rd, despite the machine being booted May 21st and 25th and June 1st.



Additionally, today (June 3rd), I actually booted my computer at 12:11, and seeing that Anacron had not started and none of my jobs were run, I rebooted the machine at 12:29. You can see on this second boot, Anacron decided to startup. Why does it just not startup a lot of the time?







anacron






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 3 '17 at 12:03









Sam Bull

1516




1516












  • Anacron does not have a just-start-sometimes-at-random feature. After a couple reboots, my Anacron starts quite reliably on my test system. Can you suggest any changes I can make to my test system that would enable me to duplicate your problem?
    – user535733
    Jun 3 '17 at 15:48










  • OK, just started looking at the init scripts, and I think I see why. Anacron must not have started because I was on battery power. Looking at the cron entries for anacron, the next time anacron will be run is 7:30am. Is this correct? It seems a bit odd that something that is meant to make cron more reliable, will completely miss everything if it's not plugged in at boot and switched off at 7:30am. So, is it an acceptable solution to change that cron entry to run every hour, or will this cause any issues? Or, better yet, run anacron every time the machine is plugged in?
    – Sam Bull
    Jun 3 '17 at 18:07










  • Hang on. Anacron is NOT an always-on (daemon/service). It's a tiny little shim of a program that runs at startup/resume, checks the timestamp files to see if any cron jobs were missed, runs them if needed, and exits. Your logs seem to indicate that Anacron was running, and simply decided that the jobs didn't need to be triggered. Before going deep into debugging Anacron, compare first the scheduled vs actual times for cron.daily and cron.weekly. The answer might be as simple as moving your cron.daily schedule to earlier in the day.
    – user535733
    Jun 3 '17 at 21:34










  • There's no anacron started message, and nothing about running cron.daily for 05/21, 05/25, 06/01 or the first time I booted my computer 06/03 at 12:11. It did not run my cron.daily scripts anytime between 05/13 and 06/03. Despite my computer having been turned on a number of times and being switched on for several hours. It looks to me like the init script is responsible for running Anacron on boot, but won't run it if on battery (/etc/init.d/anacron). And the only other time I can see it getting run is at 7:30am in /etc/cron.d/anacron.
    – Sam Bull
    Jun 4 '17 at 13:43










  • I've also just tried adding a udev rule to run anacron when plugged in. This seems to work correctly, so I think this might be the correct fix.
    – Sam Bull
    Jun 4 '17 at 14:20


















  • Anacron does not have a just-start-sometimes-at-random feature. After a couple reboots, my Anacron starts quite reliably on my test system. Can you suggest any changes I can make to my test system that would enable me to duplicate your problem?
    – user535733
    Jun 3 '17 at 15:48










  • OK, just started looking at the init scripts, and I think I see why. Anacron must not have started because I was on battery power. Looking at the cron entries for anacron, the next time anacron will be run is 7:30am. Is this correct? It seems a bit odd that something that is meant to make cron more reliable, will completely miss everything if it's not plugged in at boot and switched off at 7:30am. So, is it an acceptable solution to change that cron entry to run every hour, or will this cause any issues? Or, better yet, run anacron every time the machine is plugged in?
    – Sam Bull
    Jun 3 '17 at 18:07










  • Hang on. Anacron is NOT an always-on (daemon/service). It's a tiny little shim of a program that runs at startup/resume, checks the timestamp files to see if any cron jobs were missed, runs them if needed, and exits. Your logs seem to indicate that Anacron was running, and simply decided that the jobs didn't need to be triggered. Before going deep into debugging Anacron, compare first the scheduled vs actual times for cron.daily and cron.weekly. The answer might be as simple as moving your cron.daily schedule to earlier in the day.
    – user535733
    Jun 3 '17 at 21:34










  • There's no anacron started message, and nothing about running cron.daily for 05/21, 05/25, 06/01 or the first time I booted my computer 06/03 at 12:11. It did not run my cron.daily scripts anytime between 05/13 and 06/03. Despite my computer having been turned on a number of times and being switched on for several hours. It looks to me like the init script is responsible for running Anacron on boot, but won't run it if on battery (/etc/init.d/anacron). And the only other time I can see it getting run is at 7:30am in /etc/cron.d/anacron.
    – Sam Bull
    Jun 4 '17 at 13:43










  • I've also just tried adding a udev rule to run anacron when plugged in. This seems to work correctly, so I think this might be the correct fix.
    – Sam Bull
    Jun 4 '17 at 14:20
















Anacron does not have a just-start-sometimes-at-random feature. After a couple reboots, my Anacron starts quite reliably on my test system. Can you suggest any changes I can make to my test system that would enable me to duplicate your problem?
– user535733
Jun 3 '17 at 15:48




Anacron does not have a just-start-sometimes-at-random feature. After a couple reboots, my Anacron starts quite reliably on my test system. Can you suggest any changes I can make to my test system that would enable me to duplicate your problem?
– user535733
Jun 3 '17 at 15:48












OK, just started looking at the init scripts, and I think I see why. Anacron must not have started because I was on battery power. Looking at the cron entries for anacron, the next time anacron will be run is 7:30am. Is this correct? It seems a bit odd that something that is meant to make cron more reliable, will completely miss everything if it's not plugged in at boot and switched off at 7:30am. So, is it an acceptable solution to change that cron entry to run every hour, or will this cause any issues? Or, better yet, run anacron every time the machine is plugged in?
– Sam Bull
Jun 3 '17 at 18:07




OK, just started looking at the init scripts, and I think I see why. Anacron must not have started because I was on battery power. Looking at the cron entries for anacron, the next time anacron will be run is 7:30am. Is this correct? It seems a bit odd that something that is meant to make cron more reliable, will completely miss everything if it's not plugged in at boot and switched off at 7:30am. So, is it an acceptable solution to change that cron entry to run every hour, or will this cause any issues? Or, better yet, run anacron every time the machine is plugged in?
– Sam Bull
Jun 3 '17 at 18:07












Hang on. Anacron is NOT an always-on (daemon/service). It's a tiny little shim of a program that runs at startup/resume, checks the timestamp files to see if any cron jobs were missed, runs them if needed, and exits. Your logs seem to indicate that Anacron was running, and simply decided that the jobs didn't need to be triggered. Before going deep into debugging Anacron, compare first the scheduled vs actual times for cron.daily and cron.weekly. The answer might be as simple as moving your cron.daily schedule to earlier in the day.
– user535733
Jun 3 '17 at 21:34




Hang on. Anacron is NOT an always-on (daemon/service). It's a tiny little shim of a program that runs at startup/resume, checks the timestamp files to see if any cron jobs were missed, runs them if needed, and exits. Your logs seem to indicate that Anacron was running, and simply decided that the jobs didn't need to be triggered. Before going deep into debugging Anacron, compare first the scheduled vs actual times for cron.daily and cron.weekly. The answer might be as simple as moving your cron.daily schedule to earlier in the day.
– user535733
Jun 3 '17 at 21:34












There's no anacron started message, and nothing about running cron.daily for 05/21, 05/25, 06/01 or the first time I booted my computer 06/03 at 12:11. It did not run my cron.daily scripts anytime between 05/13 and 06/03. Despite my computer having been turned on a number of times and being switched on for several hours. It looks to me like the init script is responsible for running Anacron on boot, but won't run it if on battery (/etc/init.d/anacron). And the only other time I can see it getting run is at 7:30am in /etc/cron.d/anacron.
– Sam Bull
Jun 4 '17 at 13:43




There's no anacron started message, and nothing about running cron.daily for 05/21, 05/25, 06/01 or the first time I booted my computer 06/03 at 12:11. It did not run my cron.daily scripts anytime between 05/13 and 06/03. Despite my computer having been turned on a number of times and being switched on for several hours. It looks to me like the init script is responsible for running Anacron on boot, but won't run it if on battery (/etc/init.d/anacron). And the only other time I can see it getting run is at 7:30am in /etc/cron.d/anacron.
– Sam Bull
Jun 4 '17 at 13:43












I've also just tried adding a udev rule to run anacron when plugged in. This seems to work correctly, so I think this might be the correct fix.
– Sam Bull
Jun 4 '17 at 14:20




I've also just tried adding a udev rule to run anacron when plugged in. This seems to work correctly, so I think this might be the correct fix.
– Sam Bull
Jun 4 '17 at 14:20










2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted










Edit: This appears to have been fixed upstream in Debian 10 and Ubuntu 19.04.



So, it seems that Anacron doesn't run at startup if on battery power, and is only scheduled to run at 7:30am otherwise. The solution for me was to configure Anacron to run when power is plugged in.



This can be done by adding a script like this:





#!/bin/sh
test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null


I saved it into /etc/pm/power.d/10_anacron (make sure it is executable), which on older systems would be run automatically when plugged in. On current versions of Ubuntu, you need to add a udev rule to run the script. Just save:



SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/etc/pm/power.d/10_anacron"


to /etc/udev/rules.d/anacron.rules.






share|improve this answer






























    up vote
    1
    down vote













    An easier way: just change a line in the file /etc/default/anacron to:



    ANACRON_RUN_ON_BATTERY_POWER=yes





    share|improve this answer























    • Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
      – Sam Bull
      Aug 28 '17 at 11:04










    • Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
      – mzuther
      Aug 29 '17 at 13:36










    • Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
      – Sam Bull
      Aug 29 '17 at 17:44










    • This change doesn't works on Ubuntu 16.04
      – NicolasSmith
      Oct 26 '17 at 6:53











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f921769%2fhow-to-make-anacron-startup-reliably%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    Edit: This appears to have been fixed upstream in Debian 10 and Ubuntu 19.04.



    So, it seems that Anacron doesn't run at startup if on battery power, and is only scheduled to run at 7:30am otherwise. The solution for me was to configure Anacron to run when power is plugged in.



    This can be done by adding a script like this:





    #!/bin/sh
    test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null


    I saved it into /etc/pm/power.d/10_anacron (make sure it is executable), which on older systems would be run automatically when plugged in. On current versions of Ubuntu, you need to add a udev rule to run the script. Just save:



    SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/etc/pm/power.d/10_anacron"


    to /etc/udev/rules.d/anacron.rules.






    share|improve this answer



























      up vote
      4
      down vote



      accepted










      Edit: This appears to have been fixed upstream in Debian 10 and Ubuntu 19.04.



      So, it seems that Anacron doesn't run at startup if on battery power, and is only scheduled to run at 7:30am otherwise. The solution for me was to configure Anacron to run when power is plugged in.



      This can be done by adding a script like this:





      #!/bin/sh
      test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null


      I saved it into /etc/pm/power.d/10_anacron (make sure it is executable), which on older systems would be run automatically when plugged in. On current versions of Ubuntu, you need to add a udev rule to run the script. Just save:



      SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/etc/pm/power.d/10_anacron"


      to /etc/udev/rules.d/anacron.rules.






      share|improve this answer

























        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        Edit: This appears to have been fixed upstream in Debian 10 and Ubuntu 19.04.



        So, it seems that Anacron doesn't run at startup if on battery power, and is only scheduled to run at 7:30am otherwise. The solution for me was to configure Anacron to run when power is plugged in.



        This can be done by adding a script like this:





        #!/bin/sh
        test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null


        I saved it into /etc/pm/power.d/10_anacron (make sure it is executable), which on older systems would be run automatically when plugged in. On current versions of Ubuntu, you need to add a udev rule to run the script. Just save:



        SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/etc/pm/power.d/10_anacron"


        to /etc/udev/rules.d/anacron.rules.






        share|improve this answer














        Edit: This appears to have been fixed upstream in Debian 10 and Ubuntu 19.04.



        So, it seems that Anacron doesn't run at startup if on battery power, and is only scheduled to run at 7:30am otherwise. The solution for me was to configure Anacron to run when power is plugged in.



        This can be done by adding a script like this:





        #!/bin/sh
        test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null


        I saved it into /etc/pm/power.d/10_anacron (make sure it is executable), which on older systems would be run automatically when plugged in. On current versions of Ubuntu, you need to add a udev rule to run the script. Just save:



        SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/etc/pm/power.d/10_anacron"


        to /etc/udev/rules.d/anacron.rules.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 at 23:21

























        answered Jun 5 '17 at 17:27









        Sam Bull

        1516




        1516
























            up vote
            1
            down vote













            An easier way: just change a line in the file /etc/default/anacron to:



            ANACRON_RUN_ON_BATTERY_POWER=yes





            share|improve this answer























            • Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
              – Sam Bull
              Aug 28 '17 at 11:04










            • Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
              – mzuther
              Aug 29 '17 at 13:36










            • Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
              – Sam Bull
              Aug 29 '17 at 17:44










            • This change doesn't works on Ubuntu 16.04
              – NicolasSmith
              Oct 26 '17 at 6:53















            up vote
            1
            down vote













            An easier way: just change a line in the file /etc/default/anacron to:



            ANACRON_RUN_ON_BATTERY_POWER=yes





            share|improve this answer























            • Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
              – Sam Bull
              Aug 28 '17 at 11:04










            • Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
              – mzuther
              Aug 29 '17 at 13:36










            • Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
              – Sam Bull
              Aug 29 '17 at 17:44










            • This change doesn't works on Ubuntu 16.04
              – NicolasSmith
              Oct 26 '17 at 6:53













            up vote
            1
            down vote










            up vote
            1
            down vote









            An easier way: just change a line in the file /etc/default/anacron to:



            ANACRON_RUN_ON_BATTERY_POWER=yes





            share|improve this answer














            An easier way: just change a line in the file /etc/default/anacron to:



            ANACRON_RUN_ON_BATTERY_POWER=yes






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 14 '17 at 12:03









            dessert

            21.3k55896




            21.3k55896










            answered Aug 27 '17 at 10:19









            mzuther

            1945




            1945












            • Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
              – Sam Bull
              Aug 28 '17 at 11:04










            • Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
              – mzuther
              Aug 29 '17 at 13:36










            • Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
              – Sam Bull
              Aug 29 '17 at 17:44










            • This change doesn't works on Ubuntu 16.04
              – NicolasSmith
              Oct 26 '17 at 6:53


















            • Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
              – Sam Bull
              Aug 28 '17 at 11:04










            • Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
              – mzuther
              Aug 29 '17 at 13:36










            • Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
              – Sam Bull
              Aug 29 '17 at 17:44










            • This change doesn't works on Ubuntu 16.04
              – NicolasSmith
              Oct 26 '17 at 6:53
















            Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
            – Sam Bull
            Aug 28 '17 at 11:04




            Which would cause it to run on battery and waste power, exactly why it is set to no in the first place. It depends whether reliability or battery is a bigger issue for you. The solution I'm using has no impact on battery life, but significantly increases the reliability from the default setup.
            – Sam Bull
            Aug 28 '17 at 11:04












            Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
            – mzuther
            Aug 29 '17 at 13:36




            Ah, now I got your problem! In that case, your solution is the better one. But maybe you should edit your question so that people can immediately see that it's only about running anacron when the laptop is plugged in.
            – mzuther
            Aug 29 '17 at 13:36












            Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
            – Sam Bull
            Aug 29 '17 at 17:44




            Well, the problem was that it almost wasn't running at all. Through further digging, I figured out the issue was caused by it only running on boot (and skipping if on battery). So, my solution means that it now runs most days I use my laptop, while before it was barely running once a month.
            – Sam Bull
            Aug 29 '17 at 17:44












            This change doesn't works on Ubuntu 16.04
            – NicolasSmith
            Oct 26 '17 at 6:53




            This change doesn't works on Ubuntu 16.04
            – NicolasSmith
            Oct 26 '17 at 6:53


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f921769%2fhow-to-make-anacron-startup-reliably%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Mont Emei

            Province de Neuquén

            Journaliste