10

Drush 8.1.9 & Drupal 7.53. What I'm looking for is a command like drush ups but without all the modules that are [OK] – so when used with an alias of several sites I don't have to scroll through loads. So all I get is:

aliasname     
Name                               Installed Version  Proposed version  Message          
     Metatag (metatag)                  7.x-1.19           7.x-1.20          Update available 
     Views Slideshow (views_slideshow)  7.x-3.4            7.x-3.5           Update available 

I found drush vset update_check_disabled 1 -y && drush -n -p up – it works but here's a sample output, which is not what I want.

media_ckeditormedia_ckeditormedia_ckeditor
views_slideshowmedia_ckeditor

I also want the version info. Is there anything I can do to get a list of all modules which need an update including the version info?

5 Answers 5

11

Drush puts that [ok] information out on stderr. So you can actually just dump that by using:

drush ups 2>/dev/null

which for me gave:

 $ drush ups 2>/dev/null
 Name    Installed Version  Proposed version  Message
 Drupal  8.2.5              8.2.6             Update available
0
7

In a Drupal 8 project it's better to list updates using composer:

composer outdated 'drupal/*'
1
  • This is a great command. Its a shame the error when running drush ups doesn't suggest this as the alternative.
    – Christian
    Nov 28 at 3:06
6

Consider using 'grep'. It's not exactly a drush-specific command but will get the job done.

drush ups | grep 'Update available'

This command will return all lines that contain the phrase 'Update available'.

4
  • 1
    Yep, this is one way. For the uninitiated - this will pipe the output of drush ups to grep, which will filter by "Update available"
    – Kevin
    Jan 24, 2017 at 1:14
  • 1
    Just tried this, but I still see all the 'Checking available updates... [OK]' ones above. What it does do is get rid of the 'Name' 'Installed version' column headings above the ones that need updates, so looks like it works on the results rather than the part where drush is checking each module.
    – iain-g
    Jan 24, 2017 at 8:32
  • 1
    yeah, it processes the output from the tool itself. you can also consider custom drush commands. sitepoint.com/drupal-create-drush-command
    – kombogdan
    Jan 24, 2017 at 20:33
  • 1
    Thanks - I'll give that a go - might wait till I've learned more drush basics first :)
    – iain-g
    Jan 24, 2017 at 22:39
5

If your site is built with Composer you can use drush pm:security.

Check Drupal Composer packages for pending security updates.

This uses the Drupal security advisories package to determine if updates are available.

This will give you the following sample output:

+-------------+-------------------+-------------------+
| Name        | Installed Version | Suggested version |
+-------------+-------------------+-------------------+
| drupal/core | 8.6.7             | 8.6.10            |
+-------------+-------------------+-------------------+
-1

Using drush pm:security, you can automatically update your website using the BASH code:

SECURITY_UPDATES=$(drush pm:security --field=name | tr '\n' ' ')
SECURITY_UPDATES=${SECURITY_UPDATES//drupal\/core/drupal\/core-recommended}
      
composer update $SECURITY_UPDATES --with-dependencies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.