tags:

views:

22

answers:

1

I'm setting up a cronjob to run every 30 minutes on a Linux server.

When does the 30 minute countdown start? Is it counted from the minute I created the cronjob or is it based on a preset 30 minute schedule?

For example:

If I create a cronjob at 9:32, set to run every 30 minutes, will it run at 9:32, 10:02, 10:32, 11:02...

Or is there a predetermined run time such as it's first run would be 10:00 then 10:30, 11:00, 11:30...

+3  A: 

If you create a cron with:

*/30 * * * * /command/to/execute

it is the same as:

0,30 * * * * /command/to/execute

which means it will run twice; once on the hour and then 30 mins past the hour.

It doesn't matter what time you create it.


Another example:

*/29 * * * * /command/to/execute

is the same as:

0,29,58 * * * * /command/to/execute

So the cron will run at 00:00, 00:29, 00:58, 01:00, 01:29, 01:58 and so on.

(You can think of / as division. Every minute (*) is divided by 29...)

dogbane
@fahd, I'd add that as an addendum to the answer since it's very useful to know. Apologies for deleting my comment while you were entering yours, I'd looked it up on the net and found you were correct so my question was no longer relevant. +1.
paxdiablo