Community Documentation

Simple wget multisite cron, lazy method

Last updated March 7, 2013. Created by daven on September 17, 2009.
Edited by 2020media. Log in to edit this page.

I just wrote this script for running the crons on all my drupal sites before I discovered this section in the documentation. This works well for me because I'm lazy and I don't have to maintain a list of my drupal sites somewhere for it to run all my crons. The script simply reads the domains from my sites folder. It works well for me, but I think it might not work for every situation, ymmv.

Create an executable called drupalcron:

#!/bin/bash

#change the following line to match your sites folder
cd /var/www/drupal/htdocs/sites

#the next line gets only directories, not symlinks (and not the 'all' nor 'default' directories)
for f in `ls -Fd *.*|grep '/$'`
#remove the 'echo' from the following line after making sure it looks right
do echo wget -O - -q -t 1 http://${f}cron.php
done

Please note, the script will only echo the command and not actually do anything. This is so that you can check to see if it looks right first. Please read the comments in the script. If the output is what you expect, then delete the word echo from the do line and then it will execute the wget commands next time.

Then simply add that to your crontab however you wish:

10 * * * * /path/to/drupalcron > /dev/null 2>&1

Comments

Thanks!

This was just what I was looking for to automatically run cron for new sites that the client is adding to the multi-site installation.