Multiple cronjobs at the same time

10,846

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.

Share:
10,846
firepro20
Author by

firepro20

Updated on August 05, 2022

Comments

  • firepro20
    firepro20 over 1 year

    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?

  • firepro20
    firepro20 almost 8 years
    Excellent just what I require. Thankyou!
  • AMS
    AMS about 4 years
    For completion, if you don't care about the preceding job failing, syntax is: 0 * * * * joba.sh ; jobb.sh ; jobc.sh ; jobd.sh
  • Shadow
    Shadow about 3 years
    why we don't use cron at the same time.. ?