Linux Scheduled Tasks

Source: Internet
Author: User

1, Scheduled Tasks

Crond: Management and, when we need to execute some script commands regularly, it is very convenient and labor-saving to schedule tasks.

CRONTAB Specifies the file containing the crontab for the plan to be executed

Crontab is divided into six fields, namely Minute,hour,day,month,week,command.

which

Minute: Indicates minutes, value in 0~60;

Hour: Indicates the hour, the value is in the 0~23;

Month: Indicates the months, value in 1~12;

Week: Indicates the week, the value is in the 1~7; notice the month, day and week cannot appear simultaneously

Command: Commands that need to be executed on a timed basis enable the system to bring commands or user-defined scripts.

Asterisk (*): represents all possible values, such as the month field if it is an asterisk, the command action is executed monthly after the constraints of other fields are met.

Comma (,): You can specify a list range with a comma-separated value, for example, "1,2,5,7,8,9"

Middle Bar (-): An integer range can be represented by a middle bar between integers, such as "2-6" for "2,3,4,5,6"

Forward slash (/): You can specify the interval frequency of the time with a forward slash, such as "0-23/2", which is performed every two hours. A forward slash can be used with asterisks, such as */10, if used in the minute field, which means that it executes every 10 minutes.

2, common commands

Crontab-l: List Scheduled Tasks

CRONTAB-E: Edit mode to open a scheduled task

Crontab-r: Deleting Scheduled Tasks

3, System task scheduling

The system's scheduled tasks are saved in the/etc/crontab file, which is the author's system planning task.

The top two lines are used to configure the environment variables that the Crond task runs on, the first line of the shell variable specifies which shell the system will use, this is SH, and the second row of PATH variable specifies the path of the System execution command

4, User task scheduling

User-defined Scheduled tasks are saved in the/var/spool/cron directory

5, command example

* * * * * */xxx/xxx >/xxx 2>1&
The first five * numbers represent: minute, time, day, month, week, note that the month day and week cannot appear simultaneously. & indicates that the program is running behind. The above statement indicates that a command was executed at some point in the first place, the standard error output to the standard output, and the result output to a file

Linux Scheduled Tasks

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.