Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have 3 CentOS 6.3 Virtual Servers that I manage. I have them all set-up and configured, but am notoriously bad with remembering to run yum update on them from time to time.

Is there anyway that I can have some notification of how many updates are available, if any, when logging into the terminal via SSH. Preferably only if there are updates.

I suspect I need to configure a command to run in .bash_profile however can't seem to find the correct command using Google.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Hmm. I don't have anything handy that will tell you at logon, but...

You can install yum-updatesd and configure it to email you whenever updates are available for the system it's running on. (You could also configure it to download, or download and install, automatically.) You can also have it write to syslog, if you have something monitoring syslog that can pick it up.

It can also notify by DBus, so theoretically you could hack together a program to listen for the notification and then change /etc/motd appropriately.

share|improve this answer
    
Awesome idea. That would make things a lot simpler. –  Diago Jan 24 '13 at 19:39
3  
For completeness. yum-updatesd was removed in CentOS 6.3 and replaces with yum-cron. Configured and working. Thanks for pointing me in the right direction! –  Diago Jan 24 '13 at 20:04

Is there anyway that I can have some notification of how many updates are available, if any, when logging into the terminal via SSH.

Just to offer an alternative, you could run yum check-update on login with ~/.bash_profile. Yum-updatesd is made for this, though.

share|improve this answer

Personally, I'm a fan of simple solutions without installing unnecessary packages.

I use a simple bash script that checks whether updates are available and modifies my MOTD accordingly (it is run daily by cron). This way you will be notified of available updates each time you log in to your server (if that's not enough, you can easily use the script to send you an email or execute other tasks).

The script could actually not be simpler:

#! /bin/sh

UPDATES_COUNT=$(yum check-update --quiet | grep -v "^$" | wc -l)

if [[ $UPDATES_COUNT -gt 0 ]]; then
  echo "Updates available: ${UPDATES_COUNT}" > /etc/motd
else
  > /etc/motd
fi

I go into more detail on a blog post I wrote some time ago.

Maybe that can be a starting point for you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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