Linux CronTab regularly access php script task

Enter the command line mode first. Linux as the server generally enters the command line mode by default. Of course, our management server is generally connected to the server remotely through tools such as putty or xshell. Type in the command line:

crontab -e

After that, a file will be opened, and it is in the non-editing state, which is the editing interface of vi. You can edit the content by typing i on the keyboard and entering the editing mode. If you want to improve efficiency, using php to execute local php files is the best choice, for example:

00 */2 * * * /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

This statement can be executed every 2 hours and 0 minutes, through the Linux internal PHP environment to execute test / index. Note that here is not executed through the url access, through the server environment, but directly executed, because the server environment is bypassed, So of course the efficiency is much higher.

Ok, click the Esc key on the keyboard, enter ": wq" and press Enter. This saves the scheduled task, and you can also see the prompt to create a new scheduled task on the screen.

crontab time format:

分 时 日 月 周
第1列表示分钟1~59 每分钟用或者 */1表示,/n表示每n分钟,例如*/8就是每8分钟的意思,下面也是类推
第2列表示小时1~23(0表示0点)
第3列表示日期1~31
第4列表示月份1~12
第5列标识号星期0~6(0表示星期天)

Crontab rules in detail

  • 1. Execute every day at 6:00
0 6 * * * /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

  • 2. Every Saturday at 4:00 in the morning
0 4 * * 6 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 3. Execute at 4:05 am every Saturday
5 4 * * 6 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 4. Every Saturday at 4:15 am
15 4 * * 6 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 5. Every Saturday at 4:25 am
25 4 * * 6 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 6. Every Saturday at 4:35 am
35 4 * * 6 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 7. Every Saturday at 5:00 in the morning
5 * * 6 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 8. Every day at 8:40
40 8 * * * /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 9. Every day at 8:30
30 8 * * * /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 10. Every Monday to Friday from 11:41, every 10 minutes
41,51 11 * * 1-5   /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

1-59/10 12-23 * * 1-5   /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 11. Starting at 10:31 every day, repeat every 2 hours
31 10-23/2 * * * /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 12. Every day at 15:00
0 15 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 13. Start at 10:30 every day and repeat every 2 hours
30 10-23/2 * * * /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 14. Every day at 15:30
30 15 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 15. Every day at 17:50
50 17 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 16. Every day at 8:00
0 8 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 17. Every day at 18:00
0 18 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 18. Every day at 8:30
30 8 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 19. Every day at 20:30
30 20 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 20. Every Monday to Friday at 2:00
0 2 * * 1-5 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 21. Every Monday to Friday 9:30
30 9 * * 1-5 /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 22. Every Monday to Friday 8:00, every Monday to Friday 9:00
0 8,9 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 23. Every day at 23:59
59 23 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 24. Every Saturday 23:59
59 23 * * 6  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 25, 0:30 every day
30 0 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 26. Every Monday to Friday 9:25 to 11:35, 13:00 to 15:00, every 10 minutes
25,35,45,55  9 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

5-59/10  10 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

5,15,25,35  11 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

*/10  13-15 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 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 Execute once
30,50 8 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

30 9 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

*/30 10-11 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

30 13 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

0,30 14-15 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 28. Every day at 23:50
50 23 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 29. Every day at 10:00 and 16:00
0 10,16 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 30. Execution every day at 5:30
30 5 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 31. Every Monday to Friday at 9:30
30 9 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 32. Every Monday to Friday at 13:00
0 13 * * 1-5  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

- 33、每天7:51执行

51 7 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 34. It is executed once every day at 7:53 and 12:40
53 7 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

40 12 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 35. Every day at 7:55
55 7 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 36. Execute at 8:10, 16:00, and 20:00 once a day
10 8 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

0 16 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

0 20 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 37. It is executed once every day at 7:57 and 8:00
57 7 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index

0 8 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
  • 38. Every night from 7:00 to 5:00 in the morning, once every hour
0 19-23,0-5/1 * * *  /user/local/php/bin/php /home/wwwroot/yii(项目根目录) test/index
Published 23 original articles · praised 2 · visits 5243

Guess you like

Origin blog.csdn.net/bianlitongcn/article/details/103417816