A simple example of running a timed task under CentOS crontab

Source: Internet
Author: User
Tags centos


First, open the command line. If crontab is not installed,

1, first install crontab:

Yum Install Crontabs

Description

/sbin/service crond Start//boot service
/sbin/service Crond Stop//Off service
/sbin/service crond Restart//Restart service
/sbin/service Crond Reload//Reload Configuration
/sbin/service crond Status//view current Crond run status

2, log on to the Linux system with ordinary users. Run Crond to make sure Crond is currently running


/sbin/service crond Start//boot service

3, into the crontab VI compiler

Crontab–e

Description: The system Default editor is vim, if not please add the following shell:


Editor=vi
Export EDITOR

Basic format:

* * * * command
Time-sharing and Lunar Week command

4, open the VI compiler, enter the content

*/1 * * * Date >> $HOME/test1.txt

Save and exit, esc+shift+;


5, here, in your Desktop home folder will be one more folder

If it doesn't work, reboot.

Su Root
Cd/etc/init.d
./crond Restart

Open the home file on your desktop, and there will be a test.txt file, and you'll be able to read it every minute.


Crontab Rule Detail Instance

1, 6:00 Daily implementation

0 6 * * * root/home/www.111cn.net/osyunwei.sh

2, every Saturday 4:00 implementation

0 4 * * 6 root/home/www.111cn.net/osyunwei.sh

3, every Saturday 4:05 implementation

5 4 * * 6 root/home/www.111cn.net/osyunwei.sh

4, every Saturday 4:15 implementation

4 * * 6 root/home/www.111cn.net/osyunwei.sh

5, every Saturday 4:25 implementation

4 * * 6 root/home/www.111cn.net/osyunwei.sh

6, every Saturday 4:35 implementation

4 * * 6 root/home/www.111cn.net/osyunwei.sh

7, every Saturday 5:00 implementation

5 * * 6 root/home/www.111cn.net/osyunwei.sh

8, 8:40 Daily implementation

8 * * * root/home/www.111cn.net/osyunwei.sh

9, 8:30 Daily implementation

8 * * * root/home/www.111cn.net/osyunwei.sh

10, every Monday to Friday starting 11:41, every 10 minutes to perform a

41,51 * * 1-5 root/home/www.111cn.net/osyunwei.sh

1-59/10 12-23 * * 1-5 root/home/www.111cn.net/osyunwei.sh

11, at the beginning of the 10:31 every day, repeat every 2 hours

10-23/2 * * * root/home/www.111cn.net/osyunwei.sh

12, 15:00 Daily implementation

0 * * * * root/home/www.111cn.net/osyunwei.sh

13. Start 10:30 every day, repeat every 2 hours.

10-23/2 * * * root/home/www.111cn.net/osyunwei.sh

14, 15:30 Daily implementation

* * * root/home/www.111cn.net/osyunwei.sh

15, 17:50 Daily implementation

* * * * root/home/www.111cn.net/osyunwei.sh

16, 8:00 Daily implementation

0 8 * * * root/home/www.111cn.net/osyunwei.sh

17, 18:00 Daily implementation

0 * * * * root/home/www.111cn.net/osyunwei.sh

18, 8:30 Daily implementation

System Yun-wei Www.111cn.net warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

8 * * * root/home/www.111cn.net/osyunwei.sh

19, 20:30 every day

* * * * root/home/www.111cn.net/osyunwei.sh

20, every Monday to Friday 2:00

0 2 * * 1-5 root/home/www.111cn.net/osyunwei.sh

21, every Monday to Friday 9:30

9 * * 1-5 root/home/www.111cn.net/osyunwei.sh

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

0 8,9 * * 1-5 root/home/www.111cn.net/osyunwei.sh

23, 23:59 every day

* * * root/home/www.111cn.net/osyunwei.sh

24, every Saturday 23:59

* * 6 root/home/www.111cn.net/osyunwei.sh

25, 0:30 every day

0 * * * root/home/www.111cn.net/osyunwei.sh

26, every Monday to Friday between 9:25 to 11:35, between 13:00 to 15:00, run every 10 minutes

25,35,45,55 9 * * 1-5 root/home/www.111cn.net/osyunwei.sh

5-59/10 * * 1-5 root/home/www.111cn.net/osyunwei.sh

5,15,25,35 * * 1-5 root/home/www.111cn.net/osyunwei.sh

*/10 13-15 * * 1-5 root/home/www.111cn.net/osyunwei.sh

27, 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, the implementation of a

30,50 8 * * 1-5 root/home/www.111cn.net/osyunwei.sh

9 * * 1-5 root/home/www.111cn.net/osyunwei.sh

*/30 10-11 * * 1-5 root/home/www.111cn.net/osyunwei.sh

* * 1-5 root/home/www.111cn.net/osyunwei.sh

0,30 14-15 * * 1-5 root/home/www.111cn.net/osyunwei.sh

28, 23:50 Daily implementation

* * * * root/home/www.111cn.net/osyunwei.sh

29, every day 10:00, 16:00 execution

0 10,16 * * * root/home/www.111cn.net/osyunwei.sh

30, 5:30 Daily implementation

5 * * * root/home/www.111cn.net/osyunwei.sh

31, every Monday to Friday 9:30 implementation

9 * * 1-5 root/home/www.111cn.net/osyunwei.sh

32, every Monday to Friday 13:00 implementation

0 * * 1-5 root/home/www.111cn.net/osyunwei.sh

33, 7:51 Daily implementation

Wuyi 7 * * * root/home/www.111cn.net/osyunwei.sh

34, every day 7:53, 12:40, respectively, the implementation of one

7 * * * root/home/www.111cn.net/osyunwei.sh

* * * root/home/www.111cn.net/osyunwei.sh

35, 7:55 Daily implementation

7 * * * root/home/www.111cn.net/osyunwei.sh

36, every day 8:10, 16:00, 20:00, respectively, the implementation of one

8 * * * root/home/www.111cn.net/osyunwei.sh

0 * * * root/home/www.111cn.net/osyunwei.sh

0 * * * * root/home/www.111cn.net/osyunwei.sh

37, every day 7:57, 8:00, respectively, the implementation of one

7 * * * root/home/www.111cn.net/osyunwei.sh

0 8 * * * root/home/www.111cn.net/osyunwei.sh

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.