1. 程式人生 > >Linux計劃任務crontab設定詳解

Linux計劃任務crontab設定詳解

crontab檔案的格式:
minute hour day month weekday username command
minute:分,值為0-59
hour:小時,值為1-23
day:天,值為1-31
month:月,值為1-12
weekday:星期,值為0-6(0代表星期天,1代表星期一,以此類推)
username:要執行程式的使用者,一般設定為root
command:要執行的程式路徑(設定為絕對路徑)例如:/home/www.osyunwei.com/osyunwei.sh
附:crontab規則詳細例項
1、每天6:00執行
0 6 * * * root /home/www.osyunwei.com/osyunwei.sh
2、每週六凌晨4:00執行
0 4 * * 6 root /home/www.osyunwei.com/osyunwei.sh
3、每週六凌晨4:05執行
5 4 * * 6 root /home/www.osyunwei.com/osyunwei.sh
4、每週六凌晨4:15執行
15 4 * * 6 root /home/www.osyunwei.com/osyunwei.sh
5、每週六凌晨4:25執行
25 4 * * 6 root /home/www.osyunwei.com/osyunwei.sh
6、每週六凌晨4:35執行
35 4 * * 6 root /home/www.osyunwei.com/osyunwei.sh
7、每週六凌晨5:00執行
5 * * 6 root /home/www.osyunwei.com/osyunwei.sh
8、每天8:40執行
40 8 * * * root /home/www.osyunwei.com/osyunwei.sh
9、每天8:30執行
30 8 * * * root /home/www.osyunwei.com/osyunwei.sh
10、每週一到週五的11:41開始,每隔10分鐘執行一次
41,51 11 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
1-59/10 12-23 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
11、在每天的10:31開始,每隔2小時重複一次
31 10-23/2 * * * root /home/www.osyunwei.com/osyunwei.sh
12、每天15:00執行
0 15 * * * root /home/www.osyunwei.com/osyunwei.sh
13、每天的10:30開始,每隔2小時重複一次
30 10-23/2 * * * root /home/www.osyunwei.com/osyunwei.sh
14、每天15:30執行
30 15 * * * root /home/www.osyunwei.com/osyunwei.sh
15、每天17:50執行
50 17 * * * root /home/www.osyunwei.com/osyunwei.sh
16、每天8:00執行
0 8 * * * root /home/www.osyunwei.com/osyunwei.sh
17、每天18:00執行
0 18 * * * root /home/www.osyunwei.com/osyunwei.sh
18、每天8:30執行
30 8 * * * root /home/www.osyunwei.com/osyunwei.sh
19、每天20:30
30 20 * * * root /home/www.osyunwei.com/osyunwei.sh
20、每週一到週五2:00
0 2 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
21、每週一到週五9:30
30 9 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
22、每週一到週五8:00,每週一到週五9:00
0 8,9 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
23、每天23:59
59 23 * * * root /home/www.osyunwei.com/osyunwei.sh
24、每週六23:59
59 23 * * 6 root /home/www.osyunwei.com/osyunwei.sh
25、每天0:30
30 0 * * * root /home/www.osyunwei.com/osyunwei.sh
26、每週一到週五9:25到11:35之間、13:00到15:00之間,每隔10分鐘執行一次
25,35,45,55 9 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
5-59/10 10 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
5,15,25,35 11 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
*/10 13-15 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
27、每週一到週五8:30、8:50、9:30、10:00、10:30、11:00、11:30、13:30、14:00、14:30、5:00分別執行一次
30,50 8 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
30 9 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
*/30 10-11 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
30 13 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
0,30 14-15 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
28、每天23:50執行
50 23 * * * root /home/www.osyunwei.com/osyunwei.sh
29、每天10:00、16:00執行
0 10,16 * * * root /home/www.osyunwei.com/osyunwei.sh
30、每天5:30執行
30 5 * * * root /home/www.osyunwei.com/osyunwei.sh
31、每週一到週五9:30執行
30 9 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
32、每週一到週五13:00執行
0 13 * * 1-5 root /home/www.osyunwei.com/osyunwei.sh
33、每天7:51執行
51 7 * * * root /home/www.osyunwei.com/osyunwei.sh
34、每天7:53、12:40分別執行一次
53 7 * * * root /home/www.osyunwei.com/osyunwei.sh
40 12 * * * root /home/www.osyunwei.com/osyunwei.sh
35、每天7:55執行
55 7 * * * root /home/www.osyunwei.com/osyunwei.sh
36、每天8:10、16:00、20:00分別執行一次
10 8 * * * root /home/www.osyunwei.com/osyunwei.sh
0 16 * * * root /home/www.osyunwei.com/osyunwei.sh
0 20 * * * root /home/www.osyunwei.com/osyunwei.sh
37、每天7:57、8:00分別執行一次
57 7 * * * root /home/www.osyunwei.com/osyunwei.sh
0 8 * * * root /home/www.osyunwei.com/osyunwei.sh

轉載至 www.osyunwei.com