Crontab command usage and format

Source: Internet
Author: User

Many of the projects recently claimed use the contab timer to regularly complete file transmission, generation, transfer, and so on. It's quite helpful. I 've been very busy recently and haven't written a blog for a long time. Think about the time To summarize it ~

 

Crontab format:
1st columns minute 1 ~ 59
2nd columns hour 1 ~ 23 (0 indicates midnight)
1-3rd ~ 31
4th columns Month 1 ~ 12
5th columns in a week 0 ~ 6 (0 indicates Sunday)
6th columns of commands to run

The following is the crontab format:
Command to be run by hour, day, month, and week

Here are some examples of crontab file entries:

0 1 ***/apps/service/vscp_checking/run. Sh
Execute the run shell script one day

 

30 21 ***/usr/local/Apache/bin/apachectl restart
The preceding example indicates restarting Apache at every night.

 

45 4, 22 **/usr/local/Apache/bin/apachectl restart
The preceding example indicates that Apache is restarted at on the 1st, 10th, and 22th every month.

 

10 1 ** 6, 0/usr/local/Apache/bin/apachectl restart
The preceding example indicates that Apache is restarted at every Saturday and Sunday.

 

0, 30 18-23 ***/usr/local/Apache/bin/apachectl restart
The preceding example indicates that Apache is restarted every 30 minutes between and every day.

 

0 23 ** 6/usr/local/Apache/bin/apachectl restart
The preceding example indicates that Apache is restarted at every Saturday.

 

**/1 ***/usr/local/Apache/bin/apachectl restart
Restart Apache every hour

 

* 23-7/1 ***/usr/local/Apache/bin/apachectl restart
Restart Apache every hour between PM and PM.

 

0 11 4 * Mon-wed/usr/local/Apache/bin/apachectl restart
Restart Apache on November 4 and every Monday to Wednesday.

 

0 4 1 Jan */usr/local/Apache/bin/apachectl restart
Restart Apache at on January 1, January 1

Crontab command:
Crontab view, edit, restart, stop, start
Crontab-[L, E] service crond [restart, stop, start]

It is worth noting that when calling commands regularly in crontab, if the command is not in the classpath of crontab, the full path should be included.
For example, MySQL should be written as/usr/local/MySQL/bin/MySQL

 

Blog references http://www.blogjava.net/xiaomage234/archive/2007/12/26/170490.html

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.