6

*/15 * * * * works fine by running every 15 minutes starting from the top of the hour.

I need a task to run every 15 minutes starting from 5 minutes past the hour. Several cron simulators, eg crontab guru, say it should be 5/15 * * * *, but when I use that, nothing runs.

What should be the proper syntax?

5
  • 8
    crontab: 5,20,35,50 * * * *
    – jones0610
    Commented Oct 20, 2023 at 1:58
  • 3
    Just to point out, you said that "Several cron simulators say it should be X but when I use that, nothing runs" with a link to crontab.guru. But, on that link, there's a message written below: "Non standard! May not work with every cron.". If you use one of the two working answers, this message goes away. Commented Oct 20, 2023 at 16:17
  • 3
    for future reference: crontab.guru :)
    – Rinzwind
    Commented Oct 20, 2023 at 20:51
  • 2
    @Rinzwind, that's exactly the site they link to in their question, and exactly the site that gives the interpretation that's not valid for vixie-cron
    – ilkkachu
    Commented Oct 21, 2023 at 15:23
  • 5-50/15 * * * * will be more clear and neat.
    – FedKad
    Commented Oct 26, 2023 at 19:12

3 Answers 3

16

Either try @jones0610's suggestion, or this one:

5-59/15 * * * * command

I think 5/15 will run only once per hour, at 5 minutes past the hour.

14

This will cause your script to run every 15 minutes starting at 5 minutes past the hour. Hope this helps.

crontab: 5,20,35,50 * * * *

11

The man page crontab(5) from the package cron says:

Step values can be used in conjunction with ranges. Following a range with /<number> specifies skips of the number's value through the range. For example, 0-23/2 can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is 0,2,4,6,8,10,12,14,16,18,20,22). Steps are also permitted after an asterisk, so if you want to say "every two hours", just use */2.

It doesn't say ranges could be used with single values, so indeed 5/15 doesn't appear valid. (Even if we took it to mean every fifteen minutes within the degenerate one-value range, it'd still be just the same as just 5 and using it would be silly.)

There may be other implementations, but I believe that's the one installed by default on Ubuntu. In any case, it often pays off to consult the documentation of the software you're using instead of random internet resources which may neglect to mention the scope their explanations are valid in.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .