Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple cronjobs at the same time

What happens if I task the machine to run 4 cronjobs at the same time period say

0 * * * * joba.sh
0 * * * * jobb.sh
0 * * * * jobc.sh
0 * * * * jobd.sh

Will they be run one after each other independent of time itself or execute all at that point in time? These 4 jobs consequently in my case depend on each other so I was thinking of giving them a 1min between each of them i.e 0 1 2 3.

What do you think?

like image 524
firepro20 Avatar asked Apr 27 '16 21:04

firepro20


People also ask

Can 2 cron jobs run at the same time?

Technically it's possible to run both imports at the same time via cron jobs, but it's not recommended – actively running imports are resource-intensive and could cause your server to struggle.

How many cron jobs can run at once?

1. According to our Acceptable Use Policy, running cron jobs with intervals of less than 5 minutes or setting up more than 5 simultaneous cron jobs is not allowed on all shared servers. 2. If you do not add >/dev/null 2>&1 at the end of the command, the server will send an email notification each time a cron job runs.

Can you have multiple crontabs?

It's common that root can have multiple crontab files under /etc/cron. d/ . It's useful if you have a bundle of crontab entries that you want to maintain across multiple servers, and you don't know what changes might be made to the regular crontab.


1 Answers

Yes, cronjobs can run at the same time, and will do so if you set them up that way.

A 1 minute gap between each of the jobs might work, but what if one of them takes longer than a minute to run?

I would recommend explicitly calling them all in order:

0 * * * * joba.sh && jobb.sh && jobc.sh && jobd.sh

Note that this has the additional advantage of only calling the next job in the sequence if the previous one finished successfully.

like image 127
Hamms Avatar answered Oct 11 '22 01:10

Hamms