4

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.

3 Answers 3

3

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.

2
  • Awesome idea. That would make things a lot simpler. Jan 24, 2013 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! Jan 24, 2013 at 20:04
2

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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .