User Tools

Site Tools


If you want to send us your comments, please do so. Thanks
More on comments


Run a command with a certain interval in hours, days, weeks and months if the computer is running :-).
Only @monthly is a valid '@' interval designator.
@reboot is not valid.

Run times

Anacron runs:

WeeklySunday on 6:47
MonthlyOn the 1st of the month on 6:52

From /etc/crontab:

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

Main rule

Always put the code in a script
Start the script with

#! /bin/bash

Then call the script from anacron. If you do not use a script you can get something like

/bin/sh: 1: [[: not found

in the case you used an [[ statement for example


On servers do not user anacron, use cron


Put scripts in a file in /etc/cron.daily, /etc/cron.weekly or /etc/cron.monthly

  • They are executed after the anacrontab file is processed
  • Scripts in these directories are processed in alphanumerical order. Scripts starting with a number first

Restart service

systemctl restart anacron.service

Configuration files

/home/user/.local/anacrontabFor user specific entries
/etc/anacrontabPut the non user entries in this file



HOME=/rootOr used in crontab only?
LOGNAME=rootUsed in the From: field the e-mail. Username, may not be changed. Or used in crontab only?
MAILTO=userUser to whom the output of anacron has to be mailed
START_HOURS_RANGE=10-12In this time frame jobs are started. If missed they are skipped for that day
RANDOM_DELAY=delaytime0: off. Other value: Add a delay of 0 to delaytime minutes to the delay time (see commands section)


  • Blank lines
  • White-space only lines
  • White-space followed by a '#' followed by a comment


job-identifierMake up yourself. “ ” (space) and “/” are not allowed
commandAny shell command or script. Field separation with blank spaces or tabs
period delay job-identifier commandperiod is in days
monthly delay job-identifier commanddaily nor weekly are possible. Use the previous syntax with a period of 1 or 7

Command continuation

Place a '\' and continue the command on the next line

  4 10 backupSomething cp /home \

Options - --

Short, -, nor long, --, options are allowed. There will be an error message: “/bin/sh: 0: Illegal option -”, (long --)
Solution: write a script and have anacron run it


 # Comment
4 10 backupSomething cp /home /backup
monthly 20 backupSomething cp /home /backup
 # An other comment


Run as root

anacron -TTest the anacrontab file
anacron -T -t /home/user/.local/anacrontabTest the local user's anacrontab file
anacron -nfRun all commands now regardless the timestamp

Last run date

Check the date when an anacron job has last run in /var/spool/anacron/jobname. The format is yyyymmdd (may depend on the locale setting)

Run in user mode

anacron needs root privileges to run. You can run it in user mode. Do

  • mkdir -p /home/user/.local/spool/anacron
  • crontab -e and add:
@reboot /usr/sbin/anacron -s -t $HOME/.local/anacrontab -S $HOME/.local/spool/anacron 
@hourly /usr/sbin/anacron -s -t $HOME/.local/anacrontab -S $HOME/.local/spool/anacron 
@daily /usr/sbin/anacron -s -t $HOME/.local/anacrontab -S $HOME/.local/spool/anacron 

@hourly runs at every full hour: [0-24]:00
@daily runs very day at midnight: 0:00

man pages

  • man 8 anacron
  • man 5 anacorntab
  • man run-parts (run scripts or programs in a directory)
  • man cron

Why would anacron not be running

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

Privacy statement
Bugs statement
Copyright © : 2014 - 2023 and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
anacron.txt · Last modified: 27-02-2023 10:35 by wim