Cron工作每天上午8点到晚上8点,间隔20分钟

时间:2014-08-06 10:52:30

标签: ruby cron whenever cron-task whenever-capistrano

如何每隔{20}分钟从cron job8:00 AM运行8:00 PM,例如,cron作业应该每天从8:00 AM开始,然后在8:20 AM运行然后8:40 AM然后9:00 AM最多8:00 PM。感谢。

编辑:如何使用ruby whenever gem实现它。

1 个答案:

答案 0 :(得分:4)

只需使用两个cronjobs:

*/20 8-19 * * * /your/script
0 20 * * * /your/script

那是:

  • 每8分钟运行8到19个小时
  • 一个在20.00运行。

提醒一下,这是cronjob的格式:

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