13

If I do this:

*/9 * * * * /path/to/wotnot

At what times will the task run in two hours, starting at 09h00

Is it A:

09h00
09h09
09h18
09h27
09h36
09h45
09h54
10h03
10h12
10h21
10h30
10h39
10h48
10h57

or B:

09h00
09h09
09h18
09h27
09h36
09h45
09h54
10h00
10h09
10h18
10h27
10h36
10h45
10h54
Jesse
  • 243

2 Answers2

31

When looking at a range, you interpret it within only that column, so '*/9' within the minutes column means "list every minute, then select every ninth value". This selection resets at the top of the hour, so you restart at xx:00, xx:09, xx:18, etc every hour.

It can also be read as "every nine minutes of every hour", implying the reset at the top of the hour.

So the actual behavior you'll see corresponds to option B.

John
  • 9,208
  • 1
  • 32
  • 34
22

To confirm John's answer, */n in the minutes column means "when the minute is 0 mod n". Here is a crontab entry:

*/7 * * * *  date >> /tmp/foo

and here's the output:

Thu Jan 10 14:49:01 GMT 2013
Thu Jan 10 14:56:01 GMT 2013
Thu Jan 10 15:07:01 GMT 2013

Note the gap between the last two times is not seven minutes, because after nn:56 the next time */7 matches is `nn+1:07.

Yes, I'm aware those times are in the future (or they were when I posted this); I had to drive the system clock forward rather fast to get a quick answer.

MadHatter
  • 81,580