Henrik Petterson
Henrik Petterson

Reputation: 7094

Set a 2 cron jobs that runs every 10 minutes but don't run on top of each other

I can setup a cron every ten minutes like this:

*/10 * * * *

But I want to setup 2 cron jobs that won't run at the same time.

Is it possible to make one run every 10 minutes like this:

12.00, 12.10, 12.20, 12.30, 12.40...

And the other run:

12.05, 12.15, 12.25, 12.35, 12.45...

So both runs every 10 minutes, just not at the exact same time if that makes sense.

Upvotes: 1

Views: 3518

Answers (3)

Calumah
Calumah

Reputation: 2995

Duplicate : How can I run a cron job every 5 minutes starting from a time other than 0 minutes?

You can look at first answer : https://stackoverflow.com/a/16094616/1079254

Another simple solution is listing all minutes you want separated by commas :

5,15,25,35,45,55 * * * *

I think this syntax is more understandable for humans and it should be available in every cron software.

Upvotes: 2

Joachim Isaksson
Joachim Isaksson

Reputation: 180947

You can schedule them to start 5 minutes apart with a 10 minute cycle.

To run every 10 minutes starting at whole hours you can use;

0/10 * * * * 

...for 0, 10, 20, 30, 40, 50.

To run every 10 minutes starting at 5 past every hour;

5/10 * * * * 

...for 5, 15, 25, 35, 45, 55.

Upvotes: 2

Luismi
Luismi

Reputation: 66

Why don't you make a 5m cronjob with a Script who switch from one to another in every execution?

It's what I would do if possible. Good luck!

Upvotes: 0

Related Questions