Getting yum updates by E-mail

I run several CentOS 4.0 servers, and having to manually check each server for new updates is tedious. To simplify my life, I decided to write a shell script (yumnotifier) to E-mail me when new updates are available. The script (yumnotifier) analyzes the output from ‘yum check-update,’ and generates an E-mail similar to the following if updates are available:

From root@localhost.localdomain  Sat Jul 15 19:24:59 2006
Date: Sat, 15 Jul 2006 19:24:59 -0400
From: root 
To: matty@localhost.localdomain
Subject: Updates available for biscuit

==== The following updates are available for biscuit ===

comps.i386                               2:4.3CENTOS-0.20060314 base
gtk2.i386                                2.4.13-18              base
kernel.i686                              2.6.9-34.0.2.EL        update
libtiff.i386                             3.6.1-10               update
mysql.i386                               4.1.20-1.RHEL4.1       update
mysql-devel.i386                         4.1.20-1.RHEL4.1       update

If you manage systems that use yum, you might be interested in this script.

4 Comments

mw  on July 17th, 2007

Great script – much better than my last attempt to do this. I made a small change to ignore kernel updates and only send an email if the return code for yum check-update is not zero:

${YUM} -e0 -d0 check-update –exclude=kernel* > ${WORK}

# If there are updates available, E-mail them
if [ $? -ne "0" ]
then
REPORT=`${MKTEMP} /tmp/yum.report.XXXXXX`
echo “==== The following updates are available for ${HOST} ===” > ${REPORT}
cat ${WORK} >> ${REPORT}
cat ${REPORT} | ${MAIL} -s “Updates available for ${HOST}” ${ADMIN}
fi

Dieda  on January 17th, 2009

Thanks this is much better then when I tried it myself ;-).

Dan  on March 18th, 2009

I’ve been using the yumnotifier script for awhile, but I just discovered ‘yum-updatesd’ the other day. I’m not an expert here, so I’m just asking – how is this different from what yum-updatesd?

matty  on March 18th, 2009

Hey Dan,

When I wrote yumnotifier yum-updatesd wasn’t available. Now that it is, I have a postinstall item that updates the email_to and email_from items in /etc/yum/yum-updatesd.conf. This alleviates the need for me to install my script, and provides the same capabilities. Thanks for your comment!

- Ryan

Leave a Comment