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.

CommentFileSizeAuthor
drush_multi.sh_.txt1.12 KBnaught101

Comments

bramface’s picture

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"
hutch’s picture

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

tario’s picture

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).

SeanBannister’s picture

Subscribe. This would be so handy for upgrading our multisite installs.

SeanBannister’s picture

Just found a new drush module thats trying to work with multisite installs http://drupal.org/project/drush_multi

Surely this could just be a command line option?

greg.1.anderson’s picture

I'm planning on supporting multiple-site commands as an extension to drush site aliases. See #628996: Concurrently execute a single drush command on multiple sites. I didn't notice this incident when I created that one; one or the other of these could be closed as a duplicate.

naught101’s picture

Status: Active » Closed (duplicate)

Greg, I reckon your issue covers this one and more. Marking as a duplicate. #628996: Concurrently execute a single drush command on multiple sites

jigarius’s picture

Version: » 6.x-3.x-dev
Component: Code » Base system (internal API)
Issue summary: View changes

For people who might stumble upon this issue in times of Drupal 8+, Drall that allows you to run Drush on all/multiple sites in a multi-site Drupal installation.