The configuration of anachrontab. Linux and deadly sins part four

anacron man page

Anacron allows you to run programs even if the indicated date has passed.

We are making a list of software and tools for Linux used as a guide to the seven deadly sins list. As in the previous articles, we use laziness as an excuse to talk about automation tools in Linux. One of them in anachron. In this article we will see how is the configuration of anacrontab. anacrontab is the one that tells anacron what to do and when to do it.

In anacron the date of the tasks is fixed in days and, in case the computer is not running at the time of executing a task, it starts up when it starts up.

The anacrontab configuration

Initially anacron looks for the list of tasks to execute in the directory /etc/anacrontab. Assignments should be written in the following format:

período retraso identificador del trabajo comando donde:

  • period: Frequency with which the work must be carried out. It can be expressed in days (its abbreviation in English) period ( @daily, @weekly, or @monthly for day, week or month) or with numbers (1 for day, 7 for week, 30 for month and any number for an arbitrary period of days.
  • delay: The amount of time to wait before starting the job. For example 360 ​​to execute a task at 6 in the morning.
  • job identifier: Name assigned to the job to distinguish it from others in error and result reports
  • .

  • command: It is the instruction that anacron must execute at the indicated moment.

Since our intention is to use anacron for tasks that do not have to do with system administration, we are going to replicate the directories used by cron in our local user folder. we do it with

mkdir -p ~/.local/etc/anacrontab: ~/.local/etc/cron.daily ~/.local/etc/cron.weekly ~/.local/etc/cron.daily  ~/.var/spool/anacron

With this we create the directories to save the different daily, weekly and monthly scripts, as well as the place where the report of the last execution of anacron will be saved.

Finally, we tell anacron to use our local user folders instead of the system ones.

anacron -fn -t ~/.local/etc/anacrontab -S ~/.var/spool/anacron

Now we are going to edit a configuration file. We do it from the terminal with:

nano ~/.local/etc/anacrontab:

In the document that opens we add these lines:


These lines fulfill the same functions that we already explained for crontab. Indicate that you should use Bash as a command interpreter and in which directories to find the executables. We save the document with May + 0 and we close it with Shift + X.

The name and location of the cron folders we create is an arbitrary choice. I have chosen to keep the default ones so as not to confuse readers who require additional information from other sources. As long as the path to the script is indicated in acrontab, you can use the preferred folder and storage path. The same goes for the job identifier.

There are two other variables that we can configure:

  • : Sets the time range in which jobs will start (ie run jobs only during the following hours).

  • : This defines the maximum random delay added to the user-defined delay of a job (default is 45).

What is the difference between cron and anacron?

cron is what in systems and derivatives is known as a daemon that is, a program that runs in the background and without user intervention. It is intended for servers, that is, equipment that works almost permanently without the need for anyone to pay attention to it, but requires frequent maintenance tasks.

anacron is a normal program more suitable for desktops They are not continuously on. That is why, unlike cron, where the smallest unit of time is the minute, it works with a minimum frequency of one day.

For the same reason, cron does not include alternatives in case the computer is not turned on.
or while anacron goes through the pending tasks at login. When it finds a job not started at the set time, it will execute the command specified in the command field after waiting the number of minutes specified in the delay field. It will then log the date to a timestamp file.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.