Anacron Tools Detailed

Source: Internet
Author: User

Anacron is a similar task scheduler to Cron, except that it does not require the system to run continuously, and it can be used to run daily, weekly, and monthly jobs normally run by Cron;

To use the Anacron service, you must install the Anacron software package, Anacron service must be running;

To determine if the service is running, use the/sbin/service anacron status command

1. Configure Anacron

Anacron, like Cron, is used to schedule repetitive tasks and schedule assignments periodically.

The task is listed in the configuration file/etc/anacrontab. Each row in the file represents a task, and the format is:

Format: Period delay job-identifier Command

How often the period-command executes (days)

delay-delay Time (minutes)

The description of the job-identifier-task, used in Anacron messages and as the name of the job timestamp file, can include only non-white characters (except for slashes).

command-the command to execute

For each task, Anacron first determines whether the task has been executed within the period specified in the Period field of the configuration file. If it has not been executed for a given period, Anacron waits for the number of minutes specified in the Delay field, and then executes the command specified in the command field;

When the task is complete, anacron the date in the timestamp file in the/var/spool/anacron directory, where only the date is recorded, the time is not specified, and the Job-identifier value is used as the name of the time control file.

Anacron are similar to cron profiles, environment variables such as SHELL and PATH can be defined in the front of the/etc/anacrontab file;

Now start with the configuration file to analyze Anacron:

#/etc/anacrontab:configuration file for Anacron

# Anacron (8) and Anacrontab (5) for details.

Shell=/bin/sh

Path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

1 cron.daily run-parts/etc/cron.daily

7 cron.weekly run-parts/etc/cron.weekly

Cron.monthly run-parts/etc/cron.monthly

1, 2 line comments tell the user what the file is for, get profile help from Man 5 anacrontab.

The 3,4 line is defined as the user's basic environment variable to ensure that the program works correctly.

The 5,6,7 row is the task that is performed under the default configuration and the most important part of the task configuration.

Format is: Period delay job-identifier Command

The format is divided into four parts: the execution frequency (days), the delay time (minutes), the task description, and the command to be executed.

The first part refers to the number of days of execution, that is, how many days the task is executed, the monthly is performed within one months (30 days), and the weekly is executed once a week.

The second part refers to the retry time of the command execution, which is divided into two types:

The third part Job-identifier:anacron every time you start up a file in the/var/spool/anacron with Job-identifier as the file name, record the specified task completion time, if the task is first run, then the file is empty , just be careful not to use a string that cannot be a filename, and not a filename too long.

/sbin/service Anacron Start the service

/sbin/service Anacron stop stops the service

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.