Linux crontab Format detailed description

Source: Internet
Author: User

Crontab is a service that most Linux distributions bring with them a timed execution program. The CRONTAB-E command enables you to open a text editor to edit a timed task for the current user.

The specific format is as follows:

Name: crontab

Use Rights: All users

How to use:

crontab file [-u user]-replaces the current crontab with the specified files.

Crontab-[-u user]-replaces the current crontab with standard input.

crontab-1[user]-lists the user's current crontab.

crontab-e[user]-Edit user's current crontab.

crontab-d[user]-deletes the user's current crontab.

Crontab-c dir-Specifies the directory for crontab.

crontab file format: M H d M D cmd.


1 One task per line

2 Categorize 6 columns per task, with space or tab spacing between each column

3 The first 5 columns represent a timed cycle, and the last column represents the program

The order of the first 5 columns in 4 is: time-sharing and Lunar Week

5 means to write a specific time only at some time, and each cycle is performed with a * representative

Give a few concrete examples:

1 * * * * command (1 minutes per hour to execute orders, such as: 0 points 1 points, 1 point 1 points ...) )
* * * * Command (executed every minute, 1440 times a day)
0 0 1 * * Command (1th # 0:0 per month)

* * * */usr/local/etc/rc.d/lighttpd restart
The above example represents 21:30 restart Apache per night.

4 1,10,22 * */USR/LOCAL/ETC/RC.D/LIGHTTPD restart
The above example represents the 4:45 reboot of Apache for 1, 10, and 22nd per month.

1 * * 6,0/USR/LOCAL/ETC/RC.D/LIGHTTPD restart
The above example shows the 1:10 reboot of Apache every Saturday and Sunday.

0,30 18-23 * * * */usr/local/etc/rc.d/lighttpd restart
The example above shows that Apache is restarted every 30 minutes from 18:00 to 23:00 every day.

0 * * 6/USR/LOCAL/ETC/RC.D/LIGHTTPD restart
The above example indicates that 11:00 PM restarts Apache every Saturday.

* */1 * * * */usr/local/etc/rc.d/lighttpd restart
Restart Apache every hour

* 23-7/1 * * * */usr/local/etc/rc.d/lighttpd restart
From 11 o'clock to 7 in the morning, restart Apache every hour.

0 4 * mon-wed/usr/local/etc/rc.d/lighttpd restart
4th per month with 11 points per Monday to Wednesday restart Apache

0 4 1/USR/LOCAL/ETC/RC.D/LIGHTTPD * Restart
Restart Apache at 4 o ' January 1.

Related Article

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.