Tomaž Bratanič
Tomaž Bratanič

Reputation: 6514

Cronjob every 3 hours and cronjob every 3+1 hours

I have two sets of cronjob I want to run. First one should run every 3 hours and the second one should run also at every 3 hours but one hour later than the first set. What is the correct syntax?

// every 3 hours
17 */3  * * *   root  script
// every 3h +1 ?
17 */3+1    * * *   root  script

Upvotes: 0

Views: 144

Answers (1)

ottomeister
ottomeister

Reputation: 5808

The syntax is:

17 */3    * * *  every-3-hours-starting-at-0-script
17 1-23/3 * * *  every-3-hours-starting-at-1-script

The hour field on the first line could have been written as 0-23/3. A * in that field is just a convenient abbreviation for 0-23.

The pattern continues as you would expect. Every 3 hours starting at 2 would be:

17 2-23/3 * * *  every-3-hours-starting-at-2-script

Upvotes: 1

Related Questions