Run Drush commands on all sites in multi-site install
naught101 - July 5, 2009 - 12:05
| Project: | Drush |
| Version: | All-Versions-HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
It would be good to have the built in ability to run drush commands on all sites in a multi-site install. Obvious this would be useful for updating security fixes for modules, but also for getting info like which modules are enabled where.
I have written a bash script for this (attached), I can have a go at re-doing it in php.
| Attachment | Size |
|---|---|
| drush_multi.sh_.txt | 1.12 KB |

#1
Wonderful! We, too, run Drush on all our multisites along with our Cron jobs, non-verbosely. For more control (and because we end some sites with -com and some with -org), we call up the sites via .txt files. Attached is our method, though I don't know much Bash so it is VERY basic (therefore easy to understand to other less bashful people).
I suppose an added advantage would be to run with verbosity and save the results in a text file; instead, every now and then I run the file manually to see if there are errors.
Somebody talk me out of this....
#!/bin/sh -x
# Section 1
echo "Starting Cron Jobs"
#DRUPAL CRON JOBS
for i in `egrep -v '#' /usr/local/www/webroots/drupalcron-domains.txt`; \
do /usr/local/bin/wget --quiet -O - -t 1 http://www.$i/cron.php; \
done
echo "Finished Cron Jobs"
# Section 2
echo "Starting Updates"
#DRUPAL UPDATE JOBS
#.COM DOMAINS
for i in `egrep -v '#' /usr/local/www/webroots/drush-com.txt`; \
do cd /usr/local/www/webroots/$i-com; \
drush --q --uri=http://$i.com updatedb; \
done
echo "Com Domains Updated"
#.ORG DOMAINS
for i in `egrep -v '#' /usr/local/www/webroots/drush-org.txt`; \
do cd /usr/local/www/webroots/$i-org; \
drush --q --uri=http://$i.org updatedb; \
done
echo "Org Domains Updated"
#2
In shell scripts, you can check for exit codes, so
......do
/usr/local/bin/wget --quiet -O - -t 1 http://www.$i/cron.php
if [ $? -ne "0" ]; then
echo "uhoh, wget failed for $i"
fi
done
.....
Write the script so that it only outputs when there is a problem. If the script is running on crontab the output can be emailed.
So no errors = no email
#3
I also would like this feature very much. I think in our case it would also be a noticeable speed improvement if the loop over the projects would be done from php instead of calling the script from the outside (we have over 3000 sites).