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
  • 1
  • 6

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
  • 8,920
  • 1
  • 28
  • 34
  • This is the only answer that seems to actually answer the question. Did you try this to make sure? – gparent Jan 10 '13 at 14:29
  • Within the past 10 minutes? No. Within the past three months? Yes, though not specifically at a nine minute interval. – John Jan 10 '13 at 14:30
  • Don't see why I would care when you did but only if. Thank you. – gparent Jan 10 '13 at 14:31
  • 1
    I've had former coworkers get pissy about "no you didn't test it, you're relying on your faulty memory!" in similar situations (of course, 5 minutes later they walk away annoyed after I prove that it still works), so I've formed a habit of hedging against that in advance. – John Jan 10 '13 at 14:33
  • Can't blame them too much, I've met plenty of people who think their 5 year old experience with a deprecated product makes them experts in a different product that somewhat resembles the old one. – gparent Jan 10 '13 at 14:36
  • I can blame them for that when I'm still active in systems administration. – John Jan 10 '13 at 14:38
  • I know, I'm more referring to people who think their knowledge always lasts forever, whatever it is. I understand where your colleagues are coming from perfectly, even if you may not be that way. – gparent Jan 10 '13 at 14:39
  • Yes, your previous comment about the start time also makes sense as to why this is. – Jesse Jan 10 '13 at 14:49
  • 2
    The first step in testing is to ensure that you have the same brand and version as the customer (in this case Jesse). I don't see any clue here so far about what cron he's using. (It's likely Vixie Cron, and this basic feature is likely stable across versions of that program.) – Kaz Jan 11 '13 at 00:11
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
  • 78,442
  • 20
  • 178
  • 229