anacron
Run jobs periodically, even when system is off
SYNOPSIS
anacron [-f] [-s] [-n] [-q] [-t anacrontab] [-S spool-directory] [-u] [-T] [-V] [job] ...
PARAMETERS
-f
Force all jobs to run, ignoring timestamps.
-s
Serialize: run jobs only after previous finishes.
-n
No fork; run in foreground.
-q
Quiet mode; suppress non-error output.
-t file
Use alternate anacrontab file.
-S directory
Use custom spool directory for timestamps.
-u
Update timestamps without running jobs.
-T
Test anacrontab syntax and report timings.
-V
Print version information.
DESCRIPTION
Anacron executes commands at intervals specified in days, ideal for systems like laptops not running continuously. Unlike cron, which skips jobs if the system is off, anacron tracks missed executions via timestamps and runs them upon startup.
Jobs are defined in /etc/anacrontab, with format: period delay jobname command. Period is days between runs (e.g., 1 for daily, 7 for weekly), delay is minutes to wait before starting after anacron invokes, jobname is an identifier, and command is the shell command or script.
Anacron stores last-run timestamps in /var/spool/anacron (one file per job). Invoked typically by a daily cron job (e.g., /etc/cron.daily/anacron), it checks if jobs are overdue, waits the delay, and runs them sequentially or as configured. It handles multiple jobs, supports forcing runs, and ensures no overlaps by design.
Best for daily/weekly backups, log rotations on desktops/servers with downtime. Not for minute/hourly precision.
CAVEATS
Unsuitable for sub-daily jobs or precise timing; assumes jobs complete within period. No support for environment variables beyond anacrontab.
ANACRONTAB FORMAT
Lines: period delay jobname command
period: days (0=ASAP, 1=daily, <9999); delay: minutes; jobname: ID; command: script/shell.
Example: 1 5 cron.daily nice run-parts /etc/cron.daily
SPOOL DIRECTORY
Timestamps in /var/spool/anacron; files named jobname contain last-run date (YYYYMMDD).
HISTORY
Developed by Itai Ben-Yehuda in 1998 to address cron limitations on non-24/7 systems. Integrated into major Linux distros (Debian, Red Hat) since early 2000s; actively maintained with minor enhancements for security and compatibility.


