日期:2014-05-16  浏览次数:20716 次

crontab 8点半到10点半,每隔5分钟执行一次,怎么写
有个程序,需要每隔5分钟执行一次,时间范围是在每天晚上20:30到22:30
这种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


------解决方案--------------------
对了,上面的分钟里的“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 * * * root /bin/bash /tmp/test.sh
*/5 21 * * * root /bin/bash /tmp/test.sh
0-30/5 22 * * * root /bin/bash /tmp/test.sh
加上权限及全路径,以免有啥问题