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: rootTo: 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.








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