0

I'm running Debian and using crontab and had erroneously thought that the following would run every 35 minutes :

*/35 * * * * php /myscript.php

But it doesn't, instead it runs 'at' 35 minutes past the hour, in the same way that this does :

35 * * * * php /myscript.php

But this, for example, does run every 20 minutes:

*/20 * * * * php /myscript.php

I'm making an assumption that because it goes over 30 minutes and therefore would not be able to run every 35 minutes (because the next hour arrives) it just runs at 35 minutes past.

Is there a way (without some complicated calculations) to have my task run every 35 minutes (or 45 for that matter)?

Thank you.

omega1
  • 1,031
  • 4
  • 21
  • 41
  • I think this post is answering your question: http://stackoverflow.com/a/8182039/4751720 – lsrom Mar 29 '16 at 10:49
  • As far as I understand, there are only hacky solutions to this. Either by having multiple entries in cron or by "outsourcing" the time checks to the script that's run by cron. I typically do the time checks in the scripts themselves; i.e. run the script via cron every 15 minutes and do `if minute modulo 45 == 0: run_rest_of_script()` – jDo Mar 29 '16 at 10:50
  • Possible duplicate of [How do set cron to run my script every 40mins/25mins?](http://stackoverflow.com/questions/8181949/how-do-set-cron-to-run-my-script-every-40mins-25mins) – J. Chomel Mar 29 '16 at 12:46
  • agreed with lsrom, with the programmatic solution it gives: http://stackoverflow.com/a/31758951/6019417 – J. Chomel Mar 29 '16 at 12:47

1 Answers1

0

You can run your script every 45 minutes with three cron records:

0,45 */3 * * * php /myscript.php
30 1,4,7,10,13,16,19,22 * * * php /myscript.php
15 2,5,8,11,14,17,20,23 * * * php /myscript.php
Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31