Drupal - How to take a site offline using Drush?

Drupal 8: drush sset system.maintenance_mode TRUE

Drupal 7: drush vset maintenance_mode 1

Drupal 6: drush vset site_offline 1


First you should cd into the correct directory so that you are within the Drupal directory. If you are using a multi site installation cd into the correct sites/sitename directory or specify the correct -l setting

In Drupal 6 only this command is actually required:

$ drush vset --yes site_offline 1;

Also in Drupal 6 you can use the following commands if you wish to specify a message to show to the users of the site whilst it is down.

$ drush vset --yes site_offline_message "This site is being maintained";
$ drush vset --yes site_offline 1;

In Drupal 7 use following command to put the site into maintenance mode:

$ drush vset --yes maintenance_mode 1;

To set an a specific message use:

$ drush variable-set --yes maintenance_mode_message "This site is being maintained"

It could be necessary to clear caches that the changes of these variables take effect:

$ drush cc all

To do this with Drupal 8 and Drush 8.x use the state-set command:

drush sset system.maintenance_mode 1

At first, I assumed this would be something I would set with drush config-set system.maintenance, however the only keys in that configuration are message (the message displayed when maintenance mode is enabled) and langcode (the language code for said message).

Tags:

Drush