Drush for Multisite Cron

When running multiple Drupal sites on the same server, it can be challenging to run cron.php for each installed site. Drush can be used to solve this problem nicely.

First thing is to download drush:

http://drupal.org/project/drush

untar the tarball

tar xvzf drush-All-Versions-2.1.tar.gz

As root, copy all of the files and subdirectories in the drush directory:

cp -rp * /usr/local/bin

By placing all the drush related files and directories into /usr/local/bin, this will allow cron to execute drush. Test drush out from the commandline first like this:

drush --root=/path/to/drupal --uri=http://www.thetajoin.com cron

It should return OK ofter running. Verify in your Drupal logs that cron ran sucessfully.

After testing, start edit cron to run the above command:

crontab -e

*/17 * * * * /usr/local/bin/drush --root=/path/to/drupal --uri=http://blog.thetajoin.com cron
*/19 * * * * /usr/local/bin/drush --root=/path/to/drupal --uri=http://www.thetajoin.com cron

To make sure each site on the server wasn't updated at the exact same time, pick a time that's a prime number. I would like my Drupal sites updated roughly every 15 to 20 mins, so 19 minutes and 17 minutes will work just fine.

 

There you have it! Multisite cron using drush!

 

-- Mark

Creative Commons License
This work by Mark Schoonover is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Based on a work at blog.thetajoin.com. All comments copyright their respective owners.

Drupal SEO