I've got a pretty good handle on how cron/anacron work on linux. My question is this:
- anacron runs at login, and checks if it's been more than a day since the scripts in
/etc/cron.dailyhave run - anacron runs scripts in
/etc/cron.daily, and updates the timestamp in/var/spool/anacron/cron.daily - anacron exits
- computer stays on for more than 24 hours
- cron runs and detects a time match for cron.daily
- cron does nothing since
test -x anacrontab" == True
If my computer runs for more than 24 hours, how does cron run the scripts in cron.daily (This is a Debian based distro)?
the default /etc/crontab (which is running every minute) tests for the presence (or more precisely, the -x bit) of /usr/bin/anacron, and ignores the /etc/cron.daily folder if it finds it, but it doesn't seem to restart anacron to do the work.
EDIT:
So cron DOES start anacron from the /etc/cron.d folder, but only if the computer is on and logged in at 7:30 am every day. After doing a little spreadsheet kung-fu, I've come to the conclusion that the scripts in /etc/cron.daily will run anywhere between 1 minute and 31.5 hours apart.
Ex:
Scenario 1:
- log in at 11:59 pm on 5/23/2021
- assuming the anacron timestamp for
/etc/cron.dailyis older than 5/23/2021, anacron runs all the scrips in/etc/cron.dailyand updates the timestamp to 5/23/2021 - log out
- log back in at 12:00 am on 5/24/2021
- anacron sees that the last run was 5/23/2021, and it is now 5/24/2021, so anacron runs all the scripts in
/etc/cron.daily - elapsed time between runs: 1 minute
Scenario 2:
- log in at 12:00 am on 5/23/2021
- assuming the anacron timestamp for
/etc/cron.dailyis older than 5/23/2021, anacron runs all the scrips in/etc/cron.dailyand updates the timestamp to 5/23/2021 - computer stays on and logged in until 7:30 am on 5/23/2021
- cron runs anacron from its crontab file in
/etc/cron.d - since the timestamp is 5/23/2021, nothing happens
- computer stays on and logged in until 7:30 am on 5/24/2021
- cron runs anacron from its crontab file in
/etc/cron.d - anacron sees that the last run was 5/23/2021, and it is now 5/24/2021, so anacron runs all the scripts in
/etc/cron.daily - elapsed time between runs: 31.5 hours