All Linux HowTo's Scripting HowTo's

Get notified of Yum updates

Share This:

You can use this script to get notified of YUM updates. Just add it to your crontab and wait for the emails:

Create the script file in “/usr/bin/yum-update-notification.sh” and make it executable. Make sure to change the variables at the top of the script and also the packages to check for:

#!/bin/bash

# AGIX. check for updates and alert someone.

TO="
support@agix.local
admin1@agix.local
admin2@agix.local
"
HOSTN=`hostname`
MSG="/root/yum-updates-message.txt" # <--- Add custom text to this file. It's included in the email alert. 
TMPFILE="/tmp/yum.updatecheck"

### END OPTIONS


yum check-update | egrep -i 'php|http|mysql-server' > $TMPFILE # <--- Change the packages as needed.

if [ -s $TMPFILE ]
then
        cp $MSG $MSG.tmp
        cat  $TMPFILE >> $MSG.tmp

        for var in $TO
        do
                mail -s "$HOSTN Linux Web-Server Updates Available" $var < $MSG.tmp
        done
fi

And to make it executable:

chmod 755 /usr/bin/yum-update-notification.sh

Add it to cron and you're done.

Similar Posts: