Putting a Drupal site into maintenance mode using Drush 3.0

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by Chris Charlton on June 23, 2010 at 10:21pm

I saw someone post to how they run a custom SQL script to put a Drupal site into maintenance mode using Drush's SQL commands, but here's the easier way without any SQL code necessary. Using Drush 3.0 we can turn a site on and off in a split second using the following command:

drush vset site_offline 1

To turn the site back online we run the same command but change the 1 to a 0, like so:

drush vset site_offline 0

*To learn more about the VSET command for Drush just type: drush help vset

Categories: ,

Comments

does not work with 7.x

Posted by atchijov on August 30, 2010 at 8:09pm

It looks like 7.x uses different variable name

maintenance_mode

And, this variable value has to be number ( after vset it is string ).

And, once I patched drush to make it honor variable type (by asking old value and casting new value to the same type as old value), I can put site in "maintenance_mode", but can not get it out of it. It looks like some more magic needed (alternatively it may be D7 bug).

Any comments will be highly appreciated.

Andrei
www.touchnoc.com

Knowledge

Posted by kingandy on May 29, 2013 at 1:28pm

Drush seems to be aware of the change, and sets the right variable accordingly...

> drush vset site_offline 0
maintenance_mode was set to 0.

Correction

Posted by atchijov on August 30, 2010 at 8:14pm

Ops... it does work if you accompanies vset with cache-clear (without any patches to drush, sorry).

So to put site offline:

vset --always-set maintenance_mode 1
cache-clear all

to bring it back:

vset --always-set maintenance_mode 0
cache-clear all

Andrei
www.touchnoc.com

Why must we clear the cache there?

Posted by Jonathan Peterson on October 1, 2010 at 7:08pm

atchijov, do you know why it's necessary to clear the cache after changing the variable setting? I thought that the Drupal boot sequence checked the value of site_online/maintenance_mode before doing anything else, and that it'd note that we were in maintenance mode before bothering to check the cache. Obviously I'm wrong, but ... why?

I ask because I'd like to be able to bring my sites online or offline without invalidating the cache unnecessarily.

There is a variables cache in

Posted by moshe weitzman on January 5, 2011 at 5:00am

There is a variables cache in the 'cache' table. You could delete it with DELETE from cache WHERE cid=variables or somesuch.

Thanks, for the comment re

Posted by jrsinclair on August 31, 2010 at 12:56am

Thanks, for the comment re Drupal 7. I've been wondering how to do that for ages.

and for the noob

Posted by robertwb on September 25, 2012 at 1:29pm

For noobs to drush, like I was about 10 minutes ago - you will need to either be in the drupal install root directory that you wish to operate on, or you need to use the drush "--root" switch. So, for my case, I just took a site out of maintenance mode as follows (D7):

drush vset maintenance_mode 0 --root=/var/www/html/u/

Thanks for this little tutorial,
r.b.

thanks.

Posted by teekath on November 20, 2012 at 10:52pm

thanks. this is helpful.

drush

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /