1

I'm installing a bunch of Magento shops on a webserver. Every website has a cron job that Magento uses to update its stuff -- it takes 3-4 seconds to complete. The instructions tell to set it to run every 5 minutes.

I was asking to myself if is it advisable, for performance reasons, to set every cron to run at different minutes (e.g.: minute 0, 5, 10, etc for the first website -- minute 1, 6, 11, etc for the second and so on), to reduce overlapping, or if this is useless because linux executes multiple cron jobs at the same minute in order, avoiding concurrency.

1
  • 3
    Short answer is yes : It is advisable : If you have one cron entry per magento instance, cron jobs will run concurrently
    – user130370
    Feb 6, 2013 at 12:03

3 Answers 3

3

Depends on.

If it isn't a problem to run these cron jobs simultaneously, so they don't interfere on each other by overwriting each-others files, etc... and if your machine can handle the peak load you can run them simultaneously.

If you wan't to smear the load on your server and your scripts handle well (don't depend on when it is run) then you can run them in different minutes. Also you can also add some randomness to it if you want with sleep $(( $RANDOM%100 )); somecommand to wait 1 to 100 random seconds before executing the script.

1
  • Thank you very much! Thanks also to Sonassi, I have chose the answer from Stone because he introduced this good idea of randomness ;)
    – flip79
    Feb 7, 2013 at 12:00
3

The best thing to do here is test it.

Linux is capable of running multiple jobs at the same time. Depending on how resource intensive each job is there may be some contention if you start many jobs at the same time. Splitting them up doesn't cause any problems and would certainly reduce potential problems caused by multiple jobs starting at the same time.

0

Our shared hosting servers run up to 12 stores on a single machine - all of which are running their own cron tasks.

There is no problem at all doing this.

In terms of run schedules, we've found some modules are intolerant of the cron being executed at anything other than exactly 5 minute intervals, starting at 5 minutes past the hour.

*/5 * * * * /home/path/public_html/cron.sh
2
  • "We've found some modules are intolerant..." - which ones?
    – nickgrim
    Feb 6, 2013 at 17:34
  • 2
    */5 means exactly the same thing as 0,5,10,15,20,25,30,35,40,45,50,55.
    – mgorven
    Feb 6, 2013 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .