A collection of Drupal Drush one liners and commands

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, January 11, 2017

Follow me on Twitter as @mattiasgeniar

Some quick one-liners that can come in handy when using drush, Drupal’s command line interface.

Place all websites in Drupal maintenance mode

$ drush @sites vset site_offline 1

Place a specific multi-site website in maintenance mode

$ drush -l site_alias_name vset site_offline 1

Take all sites out of maintenance mode

$ drush @sites vset site_offline 0

Set the cache lifetime for all sites to 1800 seconds

$ drush @sites vset cache_lifetime 600
$ drush @sites vset page_cache_maximum_age 1800

List all sites in a multi-site drupal setup

$ drush @sites status
You are about to execute 'status' non-interactively (--yes forced) on all of the following targets:
  /var/www/html/site#multisite_A
  /var/www/html/site#multisite_B
Continue?  (y/n):
...

Flush all caches (varnish, memcached, …)

$ drush @sites cc all

Disable drupal’s cron

$ drush @sites vset cron_safe_threshold 0

If you know any more life-saving drush commands (you know the kind, the ones you need when all hell breaks loose and everything’s offline), let me know!



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.