3

There is a known behavior of anacron not to run when the laptop is running on batteries. Is there any way to stop this behavior and run anacron whatever the power state?

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=152402

http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg560900.html

https://bugs.launchpad.net/ubuntu/+source/anacron/+bug/36816

ECII
  • 3,997

3 Answers3

4

Please never change any files in /usr! Instead, you may change a line in the file /etc/default/anacron to

ANACRON_RUN_ON_BATTERY_POWER=yes

Thanks @Teresa e Junior. :)

1

For Debian based systems using systemd look at /usr/share/doc/anacron/README.Debian for instructions on creating /etc/systemd/system/anacron.service.d/on-ac.conf. The README tells what contents the file should be created with. This worked for me running daily snapshots with rsnapshot. I Have only tried this on Ubuntu 20.04. It seems likely that other distros may have a similar README in that directory. /etc/default/anacron has instructions to look in /usr/share/doc/anacron/README.Debian in Ubuntu 20.04. Thanks so much @mzuther : )

Just in case the README is not on someone's system the file contents should be:

[Unit]
ConditionACPower=
1

I found how to do this and summarized it in my blogpost

http://opensourceresearchtips.blogspot.com/2012/01/linux-anacron-tips.html

To change this behavior of anacron do the following:

 sudo gedit /usr/lib/pm-utils/power.d/anacron

and change to

case $1 in
    false)
 start -q anacron || :
 ;;
    true)
 start -q anacron || :
 ;;
esac
ECII
  • 3,997