如何在linux cron中设置自定义日程安排?

时间:2018-03-19 11:43:58

标签: cron

我需要在crontab中设置一个cron,应该根据以下时间表调用php文件

  

周一至周五,每分钟上午9:00至下午3:30

我试过以下,

*/1 * * * * wget http://example.com/trail.php

有人可以帮助我如何为上述要求创建一个cron吗?

谢谢,

3 个答案:

答案 0 :(得分:2)

检查cron(man 5 crontab)的联机帮助页。你可以做很多事情,但没有简单易行的方法来实现你想要的。可能最简单的方法是使用两个条目:

*    9-14 * * * <command>
0-30 15   * * * <command>

答案 1 :(得分:1)

您可以使用以下模式和代码

  

使用井号来为注释添加前缀

i2
# +---------------- minute (0 - 59)
# |  +------------- hour (0 - 23)
# |  |  +---------- day of month (1 - 31)
# |  |  |  +------- month (1 - 12)
# |  |  |  |  +---- day of week (0 - 7) (Sunday=0 or 7)
# |  |  |  |  |
# *  *  *  *  *  command to be executed
#--------------------------------------------------------------------------

答案 2 :(得分:0)

最后,得到了过时的解决方案。

*/1 9-14 * * 1-5 wget -O /dev/null example/alerts.php 

0-30 15 * * 1-5 wget -O /dev/null example/alerts.php

使这项工作像魅力一样。

感谢您的回答,从@Smit Raval和@Ulrich Eckhardt那里学习。