All HowTo's Linux Scripting in Bash Ubuntu, Mint & Debian Linux

Get notified of Yum updates

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="
[email protected]
[email protected]
[email protected]
"
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.