Crontab计划任务-wiki

计划任务实例

需求:
某个时间段,每隔5分钟执行一次
*/5 16-17

参考:https://www.cnblogs.com/intval/p/5763929.html

实例3:在上午8点到11点的第3和第15分钟执行
命令:
3,15 8-11 * * * command

实例9:每天18 : 00至23 : 00之间每隔30分钟重启smb
命令:
0,30 18-23 * * * /etc/init.d/smb restart

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

demo

  • 每天 6,9,13,16,19 点过5分执行计划任务

5 6,9,13,16,19 * * *

minute hour day month weekday

minute:分,值为0-59

hour:小时,值为1-23

day:天,值为1-31

month:月,值为1-12

weekday:星期,值为0-6(0代表星期天,1代表星期一,以此类推)

0 8,14,17 * * *

0 1,3,7,9,20,18,19,20,23 * * *

https://www.osyunwei.com/archives/5039.html

为了日志写入权限的问题,计划任务统一使用nginx用户运行

编辑计划任务使用命令: crontab -u nginx -e

参考:
http://www.bcty365.com/content-153-6160-1.html

https://blog.csdn.net/xuntianzong/article/details/22279911

https://www.cnblogs.com/kenshinobiy/p/4545676.html

原文地址:https://www.cnblogs.com/zqsb/p/11382154.html