Examples of crontab timed tasks in Linux

Source: Internet
Author: User


Grammar

Format: * * * * * * * * * * * * * * * * The task of the Year

For example, the following example performs a task every minute:


*/1 * * * */usr/bin/php/users/huangyibiao/desktop/shell/test.php >>/users/huangyibiao/desktop/shell/test.log

Common commands

To view the list of tasks in the current crontab file:


Crontab-l

If you want to suspend the task, simply comment out the task!

Go to the Crontab task List to edit:


Crontab-e

E is the meaning of edit!

Example

Execute */5 * * * * every five minutes

0 per hour * * * * * *

Daily Execution 0 0 * * *

Perform 0 0 * * 0 per week

0 0 1 * * * per month

Annual Implementation 0 0 1 1 *

Example

The above example shows the 21:30 restart Apache per night


* * * */usr/local/apache/bin/apachectlrestart

The above example represents the 4:45 restart Apache for 1, 10, and 22nd per month


4 1,10,22 * */usr/local/apache/bin/apachectlrestart

The above example shows that every Saturday, Sunday, 1:10 restart Apache


1 * * 6,0/usr/local/apache/bin/apachectlrestart

The example above shows the restart of Apache every 30 minutes from 18:00 to 23:00 every day.


0,30 18-23 * * * */usr/local/apache/bin/apachectlrestart

The above example shows the 11:00 pm reboot Apache every Saturday


0 * * 6/usr/local/apache/bin/apachectlrestart

Restart Apache every hour


* */1 * * * */usr/local/apache/bin/apachectlrestart

From 11 o'clock to 7 in the morning, restart Apache every hour.


* 23-7/1 * * * */usr/local/apache/bin/apachectlrestart

4th per month with 11 points per Monday to Wednesday restart Apache


0-4 * mon-wed/usr/local/apache/bin/apachectlrestart

Restart Apache at 4 o ' January 1.

0 4 1 jan*/usr/local/apache/bin/apachectlrestart

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.