brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: anacron runs the cron jobs that a powered-off machine missed

Cron
~/tips/tip-cron-anacron-missed-jobs

anacron -T

Runs periodic jobs after boot when the computer was off at their normal time.

Cron only fires at the scheduled minute, so a laptop or home server that is off or asleep at 03:00 never runs the job.

# /etc/anacrontab   period(days)  delay(min)  job-id  command
7   10   weekly-backup   /usr/local/bin/backup.sh

anacron -T

anacron stores the date of the last successful run in /var/spool/anacron and starts overdue jobs once the delay in minutes has passed, which spreads them out. The period is a number of days, and the Ubuntu man page lists @monthly as the only named period. anacron -T only checks the syntax of the anacrontab and runs nothing. The resolution is one day and there is no time of day, so it suits backups and cleanups, not anything that has to happen at a given hour.

Further reading: anacron(8) manual page

Going deeper: Guide: find out why a Linux service failed, with journalctl

More Cron tips echo 'systemctl restart myapp' | at 03:00 tomorrow 55 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/month-end.sh EDITOR=nano crontab -e 30 6 * * mon /usr/local/bin/weekly-report.sh @daily /usr/local/bin/backup.sh All Cron tips (32) All topics

Link