当前位置: 技术问答>linux和unix
crontab 8点半到10点半,每隔5分钟执行一次,怎么写
来源: 互联网 发布时间:2017-03-14
本文导语: 有个程序,需要每隔5分钟执行一次,时间范围是在每天晚上20:30到22:30 这种crontab该怎么写呢 | 分开写? 试试下面的: 30-60/5 20 * * * /tmp/test.sh */5 21 * * * /tmp/test.sh 0-30/5 22 * * * /tmp/test...
有个程序,需要每隔5分钟执行一次,时间范围是在每天晚上20:30到22:30
这种crontab该怎么写呢
这种crontab该怎么写呢
|
分开写?
试试下面的:
30-60/5 20 * * * /tmp/test.sh
*/5 21 * * * /tmp/test.sh
0-30/5 22 * * * /tmp/test.sh
如果系统不支持“/5”的话可以用枚举
30,35,40,45,50,55,60 20 * * * /tmp/test.sh
0,5,10,15,20,25,30,35,40,45,50,55,60 21 * * * /tmp/test.sh
0,5,10,15,20,25,30 22 * * * /tmp/test.sh
试试下面的:
30-60/5 20 * * * /tmp/test.sh
*/5 21 * * * /tmp/test.sh
0-30/5 22 * * * /tmp/test.sh
如果系统不支持“/5”的话可以用枚举
30,35,40,45,50,55,60 20 * * * /tmp/test.sh
0,5,10,15,20,25,30,35,40,45,50,55,60 21 * * * /tmp/test.sh
0,5,10,15,20,25,30 22 * * * /tmp/test.sh
|
对了,上面的分钟里的“60”要删掉。
|
“60”删掉:
30-55/5 20 * * * /tmp/test.sh
*/5 21 * * * /tmp/test.sh
0-30/5 22 * * * /tmp/test.sh
如果系统不支持“/5”的话可以用枚举
30,35,40,45,50,55 20 * * * /tmp/test.sh
0,5,10,15,20,25,30,35,40,45,50,55 21 * * * /tmp/test.sh
0,5,10,15,20,25,30 22 * * * /tmp/test.sh
30-55/5 20 * * * /tmp/test.sh
*/5 21 * * * /tmp/test.sh
0-30/5 22 * * * /tmp/test.sh
如果系统不支持“/5”的话可以用枚举
30,35,40,45,50,55 20 * * * /tmp/test.sh
0,5,10,15,20,25,30,35,40,45,50,55 21 * * * /tmp/test.sh
0,5,10,15,20,25,30 22 * * * /tmp/test.sh
|
30-55/5 20 * * * root /bin/bash /tmp/test.sh
*/5 21 * * * root /bin/bash /tmp/test.sh
0-30/5 22 * * * root /bin/bash /tmp/test.sh
加上权限及全路径,以免有啥问题
*/5 21 * * * root /bin/bash /tmp/test.sh
0-30/5 22 * * * root /bin/bash /tmp/test.sh
加上权限及全路径,以免有啥问题