[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: crontab every 5 minutes?



Andreas wrote:
On Thu, Dec 23, 2004 at 08:02:55PM -0600, Lance Hoffmeyer wrote:

Hello,

How do I get crontab to run a process every 5 minutes?
Currently, it is setup as:
5,10,15,20,25,30,35,40,45,50,55 * * *
Surely, there is a more elegant approach?

Lance

sure

*/12 * * * *
or
0-59/12 * * * *

should do it.

Sorry to post over your answer, but Andreas, this is not correct: you should have written
*/5
or
0-59/5

(every 5 minutes... your versions was "every 12 minutes". The '/' is not "divide the time into y parts" but "every time 'x MOD y = 0' then run")

For who is not used to "MOD", this is the same as "%" in some programming languages: MOD = Remainder of division
0%5 = 0
1%5 = 1
2%5 = 2
3%5 = 3
4%5 = 4
5%5 = 0
6%5 = 1
...

(Someone has already posted the solution, I just reply to your mail so that this is lot left alone and (possibly) confusing someone)


Now, I must wonder: Is there a way to "shift" this by a wanted value? (for instance, when x MOD y = 1, something like putting into cron the instance (*/5)+1 ? It would run at 1,6,11,16,21, ... Is it possible?

Joao Clemente



Reply to: