[Drupal] How to take a Drupal site offline / into maintenance mode from the command line

| | 1 min read

What do you do if you have to take your Drupal site into maintenance mode from the command line? Well you can do this easily if you have drush set up on your server. With drush you can do quite a lot powerful drupal administration tasks right from the command line.

In Drupal 6

The following drush command will take your Drupal site offline

drush vset site_offline 1

The following drush command will take your Drupal site back online

drush vdel site_offline

In Drupal 7

The following drush command will take your Drupal site offline

drush vset maintenance_mode 1 --yes

The following drush command will take your Drupal site back online

drush vset maintenance_mode 0 --yes

You might also want to clear cache using

drush cc all

to clear the cache and take the site offline for all anonymous users.