-1

Suppose, current time is 11:42 and i have setup one cron file to run at every 5 minutes.

Then this file will run at which time 11:47 or 11:45?

So basically i am trying to understand that how the cron timing is work?

Edit : it was ran at 11:45, but i don't know the reason behind it

Cron Configuration :

*/5 * * * * wget -O /dev/null http://XXX/index.php?r=controller/action
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
DS9
  • 2,995
  • 4
  • 52
  • 102
  • What did your research come up with? – PeeHaa Jul 20 '15 at 11:20
  • it was ran at 11:45, but i don't know the reason behind it,. that's why i am asking it. (and i am not able to set cron files as i have no access) – DS9 Jul 20 '15 at 11:21
  • no matter what it is the cron set timing, it will run as like 11:10,11:05,11:00 etc.. but not run like 11:01,11:02 (in case of every 5 minutes) – DS9 Jul 20 '15 at 11:25
  • 1
    This is a pretty good reference to cron and crontab: http://ss64.com/bash/crontab.html - it's really hard to answer this question without more detail, such as what the cron configuration used was, so if you could find out what that was and post that it would be good. Generally, cron works on "time of the day" not "time since it was set". But you can configure it to go every 5 minutes on the 5 minutes, or you can do every 5 minutes on 6, 11, 16 ... however you want to configure it. – GregHNZ Jul 24 '15 at 07:58
  • @GregHNZ , I have set up the cron like, `*/5 * * * * wget -O /dev/null http://XXX/index.php?r=controller/action` – DS9 Jul 24 '15 at 11:02

1 Answers1

2

As you know, cron will run jobs at a specific time.

A cron job will not use the time it was started, only the configuration matters. This means a cron job set to every 5 minutes (like your */5 * * * *) will only ever run at times ending with 0 or 5 (eg: 12:00, 12:05, 12:10), regardless of the time you run it. This makes sense because we want to schedule a job for a specific time.

If you really need a job to run every 5 minutes, with an offset (eg: 11:42, 11:47, 11:52) you will have to give a list in the configuration.

instead of (*/5 * * * *) you would need to use:

(2,7,12,...,57 * * * *), filling ... with all the other numbers.

Angzuril
  • 413
  • 3
  • 7