From Paolo Mozzati:
I tried to schedule a job that performed a daily backup through anacron on Fedora 27 on my laptop. I didn't understand why it worked by chance. I read a lot of documentation including https://docs.fedoraproject.org/f27/system-administrators-guide/monitoring-and-automation/Automating_System_Tasks.html#s1-autotasks-cron-anacron
It explains how to set up anacron and the structure of anacrontab file but not the actual process Fedora uses to run the anacron command. I found usefull this answer:
In CentOS/RHEL, anacrontab is run from cron... so you don't need to do anything. 1. cron.{daily, weekly, monthly} jobs are defined in /etc/anacrontab 2. The anacron command executes jobs defined in /etc/anacrontab 3. Anacron is called from /etc/cron.hourly/0anacron 4. /etc/cron.d/0hourly contains 01 * * * * root run-parts /etc/cron.hourly
found at: https://serverfault.com/questions/657936/do-i-need-to-restart-after-editing-anacrontab
So i look in /etc/cron.hourly/0anacron. Here the content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/sh # Check whether 0anacron was run today already if test -r /var/spool/anacron/cron.daily; then day=`cat /var/spool/anacron/cron.daily` fi if [ `date +%Y%m%d` = "$day" ]; then exit 0 fi # Do not run jobs when on battery power online=1 for psupply in AC ADP0 ; do sysfile="/sys/class/power_supply/$psupply/online" if [ -f $sysfile ] ; then if [ `cat $sysfile 2>/dev/null`x = 1x ]; then online=1 break else online=0 fi fi done
It seems to me that anacron runs only when AC power is supplied. This could be a problem since anacron is meant to be used on machine that are not always on. Typically, as was for me, a laptop that is often powered by battery. This means that my backup script could never run. I do understand that is quite dangerous to run a job running the risk to have your machine shutted down. Maybe you can indicate in the wiki that anacron run only when the machine is connected to AC.
Besided, i read in fedora guide: "Both Cron and Anacron are daemons..." As I understand so far anacron is not a daemon but just a command ran by crond.
I hope this could be useful for someone else. Best regards. Paolo Mozzati
PR: https://pagure.io/fedora-docs/system-administrators-guide/pull-request/18
Merged.
Metadata Update from @pbokoc: - Issue status updated to: Closed (was: Open)
Log in to comment on this ticket.