Posted by traviscarden on December 17, 2010 at 9:18pm
The more I learn to do with Drush, the more efficient I become. One trick that's saved me a lot of time is setting certain Drupal variables with the vset command instead of clicking through the standard admin interface—for example, putting the site in maintenance mode by setting site_offline to 1. Here are four variables I find useful to set via Drush. What are everyone else's favorites?
| Variable | Setting | Possible Values |
|---|---|---|
clean_url |
Clean URLs |
0 - Disabled1 - Enabled
|
preprocess_css |
Optimize CSS files |
0 - Disabled1 - Enabled
|
preprocess_js |
Optimize JavaScript files |
0 - Disabled1 - Enabled
|
site_offline |
Site status |
0 - Online1 - Offline
|
Edit: Attached is a pretty little printable cheatsheet of my favorites, for anyone who would like it.
| Attachment | Size |
|---|---|
| Useful Drupal 6 Variables.pdf | 177.61 KB |

Comments
theme changing
If your theme is borked, you can reset back to Garland with:
drush vset theme_default garlanddrush vset admin_theme garland
slightly off topic
but... I thought I would post this for people using a drush alias to run drush remotely on a server that uses a key for authentication instead of user/pass - like amazon ec2. I had to google around a bit to track this down.
Here's an example setup in my alias file (located in ~/.drush/aliases.drushrc.php):
<?php
$aliases['example.com'] = array (
'root' => '/var/www',
'uri' => 'example.com',
'remote-host' => 'example.com',
'remote-user' => 'ubuntu',
'ssh-options' => '-i ~/.ec2/yourkeyname.pem',
);
?>
Now you can do something like this from your local machine to affect your live remote site:
drush @example.com vset preprocess_css 0I love drush
Awesome stuff! Came just in
Awesome stuff! Came just in the right time. :)
I love drush even more now.
Mod parent up
I'm definitely a huge fan of the vset commands. Having recently enabled mod_deflate to gzip most/all of my apache traffic I updated my scripts to enforce
preprocess_css 1,preprocess_js 1,cache 1andpage_compression 0for all sites. Handy.Of course I would wrap that in
site_enabled 1andsite_enabled 0if I'm doing any serious work in my scripting.Side note: enabling mod_deflate was a huge performance win. Drush helping me make all of the sites play well with it was a huge bonus.
Useful in conjunction with
Useful in conjunction with pipe and grep - for example, to find where a module has stored a hardcoded path to something that may have changed. Like, if you had the getid3 library installed in sites/all/libraries, and decided to move it to profiles/myprofile/libraries.
drush vget | grep 'all/libraries'--
Tom
www.systemseed.com - drupal development. drupal training. drupal support.
how do you vset a variable
how do you vset a variable that is inside a nested array?
drush vset foo[bar][0]
???
I don't think you can set
I don't think you can set complex variables like that, but you can always do:
drush php-eval "variable_set(array('foo' => array('bar' => 0)));"knaddison blog | Morris Animal Foundation
The help for vget recently
The help for vget recently added examples of setting complex values http://www.drush.org/help/5#variable-set.
My favorite is on emergency
My favorite is on emergency :p
Yesterday I was called because a site had a high load (system load in 60!). As soon as I could access via ssh just set aggresive cache + 5 minutes in cache with:
drush vset cache 2drush vset cache_lifetime 300
then it was workable to do other optimizations.
PS. on a 2nd thought: same thing can be done quicker by editing settings.php
thanks!... nice tip.. now i
thanks!... nice tip.. now i know about "aggressive cache" - A cache which skips the boot and exit of a drupal system.
Disable email notifications about module updates
How can we disable module update notifications emails through vset. We can remove email id from /admin/reports/updates/settings
See:
See: http://drupal.stackexchange.com/questions/97827/drush-disable-module-upd...