anacron can execute commands or scripts periodically; this tool comes from the cronie package as well.

Options

Here are some options for anacron command:

Option Description
-f Force all jobs to run.
-u Update the timestamp of all jobs to the current date.
-s Have anacron execute the jobs in order.
-n Run all jobs immediately, regardless of the delay time.
-d Let anacron run in the foreground, print messages to standard error output and syslog log file.
-q Force anacron to send any message to standard error output, which must be used with the -d parameter.
-t anacrontab_file Use the specified anacrontab profile instead of the default /etc/anacrontab file.
-T Test whether the syntax of the /etc/anacrontab configuration file is correct, return code 1 if syntax is wrong, and return code 0 if syntax is correct.
-S spool_path Specify a path to keep the timestamps instead of the default /var/spool/anacron directory.

Examples

Number of Jobs Anacron Can Be Execute Concurrently

1
2
# Anacron uses up to two file descriptors for each active job
echo $(($(ulimit -n) / 2))
img

Check Anacrontab Configuration

1
cat /etc/anacrontab
img

Here are some configuration fields in /etc/anacrontab file:

Field Description
RANDOM_DELAY The maximum number of minutes that can be delayed.
START_HOURS_RANGE Specify an executable time range, so long as the machine is running within the time range, the job will be executed.

Here are some columns in /etc/anacrontab file:

Column Description
Column 1 How many days are a cycle.
Column 2 The number of minutes delayed.
Column 3 The unique name of the job used when logging.
Last columns Directory of commands or scripts to execute.

References ANACRON(8), ANACRONTAB(5)

Buy me a coffeeBuy me a coffee