Since drush 9 (drupal 8.4 requirement), alias @sites does not seem to be implemented anymore (or yet ?).

$ drush @sites cr
The alias @sites could not be found.

Is this a way to get the same behavior that does not consist of typing my 300 alias in a config file ?


Waiting something similar, I wrote this small script I called "drall" you may adapt:


// Path to sites.php file.

$done = [];
$argv = $_SERVER['argv'];


$parameters     = implode(' ', $_SERVER['argv']);
$commandPattern = "drush --uri=:key $parameters";

foreach ($sites as $key => $site) {

  if (count($argv) > 1 && !in_array($site, $done)) {

    $command = str_replace(':key', $key, $commandPattern);
    echo "Executing command `$command` on $site\n";
    $done[] = $site;

Use example:

$ ./drall cc render
Executing command `drush --uri=xxxxxxx cc render` on default
 [success] 'render' cache was cleared.

Hope there will be some @sites behaviors later, that was helpfull.

Although from this issue it doesn't look like it:

Drush 9 no longer supports executing a single command on multiple sites with alias lists (@A,@b,@c) or @sites. Neither of those syntaxes are available in any context. You may still use drush sa @group to see all aliases in a group; that is the only context in which Drush recognizes alias lists.

| improve this answer | |
  • Thank you, the script works just fine. One thing which doestn work, are the promts. you cannot see them but can interact with them. Any ideas how to enhance your script? – anonym-developer Jun 5 '18 at 20:23
  • tried echo `$command`; but it shows me only the output not the prompts – anonym-developer Jun 5 '18 at 20:33
  • use -y at the end of your command, it will not show the y/n prompt this way. – Oulalahakabu Jun 11 '18 at 6:28
  • What if I do want to see them? E.g. config-import. – anonym-developer Jun 11 '18 at 6:45
  • maybe run it in a single site before – Oulalahakabu Jun 11 '18 at 6:53

I'd simply place a lightweight loop into your ~/.bashrc or ~/.bash_profile or where ever you prefer. Just update the SITES=( foo bar ) array to your needs.

Source your bash file, cd into your multi-site root and call ddrush cim -y for example and it will iterate through all sites provided in the SITES array.

ddrush () {
  # Provide an array of sites you want to loop.
  SITES=( foo bar )

  # Validate and hint if no argument provided.
  if [ "${#}" -eq 0 ]; then
    echo "- ddrush: missing argument(s)"
    echo "EXAMPLE: ddrush cex -y"
    # Loop:
    for SITE in "${SITES[@]}"; do
      echo "drush -l ${SITE} ${@}"
      drush -l "${SITE}" "${@}"

You can use nearly the same for running a deployment script. Or you could easily provide multiple aliases like that. adrush, bdrush, cdrush – one for every multi-site environment you need to maintain.

I only now read you have 300 instances running. Respect! Well, then it might be easier to only provide an absolute path to the sites folder and have that scanned and then looped through automatically.

xdrush () {
  # Provide the absolute path to the sites directory.

  # Validate and hint if no argument provided.
  if [ "${#}" -eq 0 ]; then
    echo "- xdrush: missing argument(s)"
    echo "EXAMPLE: xdrush cex -y"
    cd "${SITES}"
    # Loop:
    for SITE in $(ls -d */ | cut -f1 -d'/'); do
      # Skip default site.
      if [ ! "${SITE}" == "default" ]; then
        cd "${PWD}"
        echo "drush -l ${SITE} ${@}"
        drush -l "${SITE}" "${@}"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.