anacron Command Cheatsheet
anacron is a scheduler for systems that are not always running. It guarantees daily/weekly/monthly jobs run even after downtime.
What is anacron
Used on laptops and desktops where cron may miss scheduled jobs if the machine is powered off. anacron records last run timestamps in /var/spool/anacron and executes overdue jobs at startup.
Default config file
Typical location: /etc/anacrontab
# period delay job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 10 cron.weekly nice run-parts /etc/cron.weekly
30 15 cron.monthly nice run-parts /etc/cron.monthly
period: number of days between runs (1,7,30)delay: start delay in minutes after anacronjob-identifier: unique name that determines the timestamp filecommand: command to execute
Standard anacron usage
The canonical distro setup keeps anacrontab small by using three jobs: cron.daily, cron.weekly, cron.monthly. The actual scripts are in /etc/cron.daily etc., and anacron runs them post-boot.
nice run-parts /etc/cron.daily means:
nice: reduce scheduler priority (be less aggressive).run-parts: execute every executable script in the directory.
Common anacron commands
sudo anacron -fForce-run all jobs now (ignores timestamps).
anacron -nRun jobs without delay (non-daemon mode).
anacron -S /etc/anacrontabExtract commands from config (useful for debugging) with no execution.
anacron -t /etc/anacrontab -fRun using alternative config path.
anacron vs cron
- cron schedules min/hour/day+ with fine granularity; requires daemon always running.
- anacron schedules only day-based jobs (days, weeks, months); recovers after downtime.
- cron uses user crontab; anacron uses system config
/etc/anacrontab, normally root-owned. - anacron is not suitable for per-minute tasks.
Troubleshooting & tips
- Check status with
systemctl status anacronon systemd systems. - Verify history path:
/var/spool/anacronhas timestamp files per job. - Use
anacron -ffor testing to avoid waiting for period. - Keep anacron and cron job definitions in lockstep to avoid duplication.