4

I want to set up a job to run every 15 minutes, starting at the 5th minute.

This is my crontab line:

5/15 * * * * /root/job.sh >> /root/job.log

But it only runs once an hour, on the fifth minute. I confirmed by checking /var/log/syslog.

On Debian 7.8.

2 Answers 2

5

Have you looked at this?

I think what you are looking for is:

5-59/15 * * * * /root/job.sh >> /root/job.log
3
  • 1
    I like your Stackoverflow link
    – roaima
    Feb 20, 2015 at 23:06
  • Thanks, that's a great link. I'd looked for a similar scenario but I guess I didn't think of the right keywords in order to find that discussion. Obviously the part I missed is that I actually needed to specify a range for the stepping to work. Thank you.
    – Saul
    Feb 23, 2015 at 17:46
  • 1
    Another great link: crontab.guru. Shame on me, I didn't notice the Non standard! May not work with every cron warning, and only this question explained it. Oct 24, 2021 at 20:44
2

What you've written in your crontab entry doesn't match your stated need. The manpage (man 5 crontab) is reasonably clear on this:

Step values can be used in conjunction with ranges. Following a range with "/" 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 [...]

To run every 15 minutes starting at 5 minutes past the hour, I'd go for the simple 5,20,35,50. A step value such as 5-59/15 should also work, but in this instance I'd suggest that its intent is less obvious.

1
  • Thanks for replying -- I had ended up with a simple list but was hoping for a more elegant solution. BTW, after realizing that a range is required for the step to work, it looks to me like 5/3 wouldn't work either.
    – Saul
    Feb 23, 2015 at 17:48

You must log in to answer this question.

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