Browse Docs

⏲️ Cron & Anacron

On this page

Configurations

  • /etc/crontab : the daemon’s configuration file, defining the default behaviour of crond (SHELL, MAILTO, etc.).
  • /etc/cron.d/... : system crontab (used by admins).
  • /var/spool/cron/root : crontab per user.
1MAILTO="admin@example.com"
2* * * * *  root  /usr/local/sbin/mycommand.sh > /dev/null 2>&1

Anacron

  • /etc/anacrontab : file that runs, via the run-parts command, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly.
  • /etc/cron.d/0hourly : exception, runs /etc/cron.hourly via run-parts, checking the last run of the task in /var/spool/anacron/....

Special cases

Exactly the last day of each month:

1* 5 * * * [ $(date --date=tomorrow +%d) -eq 1 ] && /bin/my/script/backup/example

Every Monday, but only once every two weeks:

130 1 * * 1 [ $(expr $(date +%W) % 2) -eq 1 ] && /home/oracle/dba/backup/bin/oracle_rman_backup.sh FULL > /dev/null 2>&1

Log

1/var/log/cron
Sunday, October 4, 2026 Wednesday, August 16, 2023