computer_science:linux:anacron

Using anacron instead of cron

Part of Linux

Sometimes, you want a job to be run, but you don't want to / can't assume that the host will be up and ready.

If that is the case, cron will not be an ideal fit, since it assume the last job was run as expected.

For this cases, we can use anacron. Do note that anacron only uses days, and not hours in it's calculations

Using the following example:

7  15  test.daily  /bin/sh  /home/username/script.sh

Clarification

ValueExplanation
7Number of days between each job execution
15Delay in minutes, to run the job if the job is due
test.dailyUnique name identifier for the job
/bin/shBash to use
/home/username/script.shScript Location


To install anacron (in Debian):

sudo apt install anacron -y

To edit anacron information:

sudo nano /etc/anacron
  • computer_science/linux/anacron.txt
  • Last modified: 2023/12/01 12:07
  • by 127.0.0.1