2012-08-11 176 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 * * * * 
相關問題