Crontab format in linux

Source: Internet
Author: User

Crontab is a common timing function in linux. It can also be called the scheduled task function. Next I will introduce some formats and usage of crontab commands.

Crontab is a service that comes with a scheduled execution program in most Linux releases. You can use the crontab-e command to open a text editor to edit the scheduled tasks of the current user.

The specific format is as follows:

Name: crontab

Permission: All Users

Usage:

Crontab file [-u user]-replace the current crontab with the specified file.

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

Crontab-1 [user]-list the current crontab of the user.

Crontab-e [user]-edit the current crontab of the user.

Crontab-d [user]-delete the current crontab of the user.

Crontab-c dir-specifies the crontab directory.

Crontab file format: m h d m d cmd.


1. One task per line

2. Each task is classified into six columns, and each column is separated by spaces or tabs.

3. The first five columns represent the scheduled period, and the last column represents the program.

4. The order of the first five columns is: hour, day, month, and week.

5 indicates that a specific time is written for execution only at a specific time, and * indicates that each cycle is executed.

For example:

1 *** command (the command is executed every hour, for example, and so on ......)
* *** Command (executed every minute, 1440 times a day)
0 0 1 ** command (executed at 00:00 on the first day of every month)

30 21 ***/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates restarting apache at every night.

45 4, 10, 22 **/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates that apache is restarted at on the 1st, 10th, and 22th every month.

10 1 ** 6, 0/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates that apache is restarted at every Saturday and Sunday.

0, 30 18-23 ***/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates that apache is restarted every 30 minutes between and every day.

0 23 ** 6/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates that apache is restarted at every Saturday.

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

* 23-7/1 ***/usr/local/etc/rc. d/lighttpd restart
Restart apache every hour between PM and PM.

0 11 4 * mon-wed/usr/local/etc/rc. d/lighttpd restart
Restart apache on November 4 and every Monday to Wednesday.

0 4 1 jan */usr/local/etc/rc. d/lighttpd restart
Restart apache at on January 1, January 1

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.