Crontab Plan Execution Script detailed

Source: Internet
Author: User

Crontab is a tool that executes a program at a fixed time in a Linux system, similar to a Task scheduler in a Windows system.

First, install the crontab

Yum Install Vixie-cron #安装

Chkconfig Crond on #设为开机启动, installing Chkconfig (yum install chkconfig) # # #设置启动方式

Service Crond Start #启动

Service Crond Stop #停止

Or

/etc/rc.d/init.d/crond Start/stop/restart/reload

/etc/rc.d/init.d/crond Reload # Non-disruptive service, reload configuration

Second, the meaning of the crontab parameter

The Cron service provides the crontab command to set the cron service , with detailed parameters as follows

Crontab-u//Set a user's Cron service, which is usually required by the root user when executing this command

CRONTAB-L//list details of a user cron service

Crontab-r//Delete a cron service with no users

CRONTAB-E//Edit a user's cron service

Iii. set up a task plan

/home/mvp/osyunwei.sh #要自动执行的脚本程序路径

chmod +x/home/mvp/osyunwei.sh #对脚本文件添加执行权限, otherwise cannot be executed

Vi/etc/crontab #编辑配置文件, adding content on the last line

1 * * * root/home/mvp/osyunwei.sh #表示每天凌晨1点30执行备份

: wq! #保存退出

/etc/rc.d/init.d/crond Reload #重新载入crond配置文件

Crontab file Format:

minute Hour    Day Month Weekday username command

minute: Minute, value is 0-59

Hour: Hour with a value of 1-23

Day: Days with a value of 1-31

Month: The value is 1-12

Weekday: Week, value 0-6 (0 for Sunday, 1 for Monday, etc.)

Username: The user to execute the program is generally set to root

Command: Program path to execute ( set to absolute path ) For example:/home/mvp/osyunwei.sh

*/2 every 2

1-6 1 to 6

1,2,3,4 1, 2, 3, 4

Detailed examples of rules attached to crontab

1, Daily 6:00 execution

0 6 * * * root/home/mvp/osyunwei.sh

2, every Saturday 4:00 to execute

0 4 * * 6 root/home/mvp/osyunwei.sh

3, every Saturday 4:05 to execute

5 4 * * 6 root/home/mvp/osyunwei.sh

4, every Saturday 4:15 to execute

4 * * 6 root/home/mvp/osyunwei.sh

5, every Saturday 4:25 to execute

4 * * 6 root/home/mvp/osyunwei.sh

6, every Saturday 4:35 to execute

4 * * 6 root/home/mvp/osyunwei.sh

7, every Saturday 5:00 to execute

5 * * 6 root/home/mvp/osyunwei.sh

8, Daily 8:40 execution

8 * * * root/home/mvp/osyunwei.sh

9, Daily 8:30 execution

8 * * * root/home/mvp/osyunwei.sh

10, every Monday to Friday, starting 11:41, every 10 minutes to perform a #值得借鉴

41,51 * * 1-5 root/home/mvp/osyunwei.sh

Or

1-59/10 12-23 * * 1-5 root/home/mvp/osyunwei.sh

11. Repeat every 2 hours, starting at 10:31 every day.

10-23/2 * * * root/home/mvp/osyunwei.sh

12, Daily 15:00 execution

0 * * * root/home/mvp/osyunwei.sh

13, starting 10:30 every day, repeat every 2 hours

10-23/2 * * * root/home/mvp/osyunwei.sh

14, Daily 15:30 execution

* * * * root/home/mvp/osyunwei.sh

15, Daily 17:50 execution

* * * * root/home/mvp/osyunwei.sh

16, Daily 8:00 execution

0 8 * * * root/home/mvp/osyunwei.sh

17, Daily 18:00 execution

0 * * * root/home/mvp/osyunwei.sh

18, Daily 8:30 execution

8 * * * root/home/mvp/osyunwei.sh

19, every day 20:30

* * * * root/home/mvp/osyunwei.sh

20, every Monday to Friday 2:00

0 2 * * 1-5 root/home/mvp/osyunwei.sh

21, every Monday to Friday 9:30

9 * * 1-5 root/home/mvp/osyunwei.sh

22, every Monday to Friday 8:00, every Monday to Friday 9:00

0 8,9 * * 1-5 root/home/mvp/osyunwei.sh

23, every day 23:59

* * * * root/home/mvp/osyunwei.sh

24, every Saturday 23:59

* * 6 root/home/mvp/osyunwei.sh

25, every day 0:30

0 * * * root/home/mvp/osyunwei.sh

26. Run every 10 minutes from Monday to Friday from 9:25 to 11:35, between 13:00 and 15:00

Sub-section writing is worth borrowing from

25,35,45,55 9 * * 1-5 root/home/mvp/osyunwei.sh

5-59/10 * * 1-5 root/home/mvp/osyunwei.sh

5,15,25,35 * * 1-5 root/home/mvp/osyunwei.sh

*/10 13-15 * * 1-5 root/home/mvp/osyunwei.sh

27. Execute once every Monday to Friday 8:30, 8:50, 9:30, 10:00, 10:30, 11:00, 11:30, 13:30, 14:00, 14:30, 5:00, respectively

30,50 8 * * 1-5 root/home/mvp/osyunwei.sh

9 * * 1-5 root/home/mvp/osyunwei.sh

*/30 10-11 * * 1-5 root/home/mvp/osyunwei.sh

* * 1-5 root/home/mvp/osyunwei.sh

0,30 14-15 * * 1-5 root/home/mvp/osyunwei.sh

28, Daily 23:50 execution

* * * * root/home/mvp/osyunwei.sh

29, Daily 10:00, 16:00 execution

0 10,16 * * * root/home/mvp/osyunwei.sh

30, Daily 5:30 execution

5 * * * root/home/mvp/osyunwei.sh

31, every Monday to Friday 9:30 to execute

9 * * 1-5 root/home/mvp/osyunwei.sh

32, every Monday to Friday 13:00 to execute

0 * * 1-5 root/home/mvp/osyunwei.sh

33, Daily 7:51 execution

Wuyi 7 * * * root/home/mvp/osyunwei.sh

34, each day 7:53, 12:40 to perform one time

7 * * * root/home/mvp/osyunwei.sh

* * * * root/home/mvp/osyunwei.sh

35, Daily 7:55 execution

7 * * * root/home/mvp/osyunwei.sh

36, each day 8:10, 16:00, 20:00 to perform one time

8 * * * root/home/mvp/osyunwei.sh

0 * * * root/home/mvp/osyunwei.sh

0 * * * root/home/mvp/osyunwei.sh

37, each day 7:57, 8:00 to perform one time

7 * * * root/home/mvp/osyunwei.sh

0 8 * * * root/home/mvp/osyunwei.sh

Crontab Plan Execution Script detailed

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.