Cron/crontab of Linux task scheduling and periodic task execution

Source: Internet
Author: User

A recurring task schedule requires a package, uninterrupted monitoring time. CentOS7 need main package: Cronie (provides crond daemon and related AIDS)

Recurring task scheduling requires first ensuring that the Crond daemon is running

Crond need to use a dedicated configuration file, this file has a fixed format, it is not recommended to use a text editor to edit this file directly, to use the crontab command

System Cron Task: Mainly used to implement its own maintenance files are located in:/etc/crontab



Note: The command directory specified in path is not many, if the original parameters, there are many executed commands need to write the absolute path of the command, it is recommended to redefine the path parameter

Each row defines a recurring task

Each user has its own recurring task profile

This directory is accessible only to the root user


Time Example:

1, 3 * * * * * What does it mean?

For the first 3 minutes of each hour, the trick is to look at the next bit of time.

2, 3 4 * * 5 mean what?

Perform tasks every Friday 4:3

3, 5 6 7 * * What does it mean?

7th, 6, five points per month.

4, 7 8 9 10 * What does it mean?

October 9 8:7 Every year to perform tasks

5, 9 8 * * 3, 7 means what?

Every Wednesday, Sunday, 8:9. Perform tasks

6, 0 8,20 * * 3, 7 means what?

8-and 20-point missions every Wednesday Sunday

7, 0 9-17 * * 1-5 mean what?

Working hours Monday to Friday from 9 to 17 points on the hour to perform the task

8, */2 * * * * * What do you mean?

Perform a task every 2 minutes, if every 7 minutes? This is difficult, because 7 cannot be divisible by 60, and the last task is not executed.



Crontab options:

-U executes the command user, if not specified is the operator itself

-L (L) view current recurring schedule

-R Delete the current user all cycle plan, want to delete a cycle plan what to do? Delete in edit mode

-e Edit a cycle plan

-I interaction

Create/Edit a cycle plan script

The file content is the cycle plan of the script that the user all of the cycle plan script more written in this file

Note: The% number has a special meaning in the crontab command if there are% in the script that need to be escaped

Once created, you can view the Cycle plan script

To view recurring plan execution results you need to use mail

Delete a user's recurring schedule and scripts

Write cycle plans for other users through root


Cron/crontab of Linux task scheduling and periodic task execution

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.