Introduction to Linux: anacron commands in Linux

Source: Internet
Author: User

Introduction to Linux: anacron commands in Linux

If our Linux host is in the starting status all day long, we only need the atd and crond services. If our server is not started 24 hours a day, then we need anacron's help.

Anacron cannot replace cron to run a task. Instead, it performs anacron operations in days or immediately after startup, it detects the crontab task that should be executed but not performed during the downtime and runs the task again, then anacron stops automatically.

Anacron detects ongoing crontab tasks in the system every day, seven days, or one month. Therefore, it is very helpful for some special use environments. Anacron will analyze the time of the last running of anacron recorded in the current time and time record. If there is a difference between the two, that is, no crontab is performed at some time points, then anacron will start executing the non-running crontab. Therefore, anacron has heard of crontab for running. Therefore, anacron usually runs at two times, one during system startup and the other in a crontab scheduling, this allows you to analyze crontab tasks that are not performed by the system at a specific time. We can use ll/etc/cron */* ana * to view the anacron detection time. However, if we analyze the file carefully, we find that it mainly executes the anacron command.

The syntax of the anacron command is as follows:

(1)-s starts to run various tasks consecutively, and records the data at a time to determine whether or not to proceed.

(2)-f is enforced without judging the timestamp of the time logon file.

(3)-n: Do not delay the waiting time for ongoing tasks immediately.

(4)-u only indicates the timestamp of the update time record and does not perform any work.

The configuration file of anacron is/etc/anacrontab, and many of its contents are saved in/var/spool/anacron.

When anacron releases anacron-s cron. daily, it performs the following steps:

(1) The number of days from/etc/anacrontab analysis to cron. daily is one day.

(2) obtain the timestamp of the last running anacron from/var/spool/anacron/cron. daily.

(3) Compare the retrieved timestamp with the current timestamp. If the difference exceeds one day, prepare the command.

(4) If you are about to run the command, the configuration of/etc/anacrontab will be delayed for 65 minutes.

(5) After the delay, run the subsequent commands, namely run-parts/etc/cron. daily.

(6) After running, the anacron program ends.

Linux scheduled task (at batch crontab anacron)

This article permanently updates the link address:

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.