2012-08-11 172 views

回答

35

正确的解决方案:

* 11,16,21 * * * 

因为如果使用以前的解决方案:

0-59 11-12,16-17,21-22 * * * * 

工作将在12:40或17:59开始。它不在11AM至12AM,4PM至5PM和9PM至10PM的范围内。

UPDATE:

传统的cron格式(从Unix继承)由五个字段由空格分开的:

* * * * * command to be executed 
┬ ┬ ┬ ┬ ┬ 
│ │ │ │ │ 
│ │ │ │ │ 
│ │ │ │ └───── day of week (0 - 6) (0 is Sunday, or use names) 
│ │ │ └────────── month (1 - 12) 
│ │ └─────────────── day of month (1 - 31) 
│ └──────────────────── hour (0 - 23) 
└───────────────────────── min (0 - 59) 

nnCron可以同时使用传统的和cron格式的 “增强的” 版本,其中有一个额外的(第六)字段:年份。

+2

+1。很好的接收。 – SiB 2012-08-11 12:17:12

+0

我登录只是为了对此答案投票。非常好地解释 – 2014-06-06 11:26:28

4

由于每cron format

<Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week> <Year> 

* * * * * * 
| | | | | | 
| | | | | +-- Year    (range: 1900-3000) 
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday) 
| | | +------ Month of the Year (range: 1-12) 
| | +-------- Day of the Month (range: 1-31) 
| +---------- Hour    (range: 0-23) 
+------------ Minute   (range: 0-59) 

溶液应

* 11,16,21 * * * * 
相关问题