Archive

Posts Tagged ‘yum’

Weekly errata Report for YUM based machines

October 10th, 2009 1 comment

I had a request the other day at the Utah Open Source Conference to share a very small script that I have that checks for, and reports any available updates on a YUM based machine. This means CentOS, RHEL, Fedora, etc. I have been using this script at work for some time now and, by placing it in the /etc/cron.weekly/ directory, it reports to me on what packages are available for update. I find this to be a simpler solution than manually checking and trying to keep on top of all of my machines all the time.

I have outlined two revisions of this script below. The first one has properly formatted reports, the second one only reports if there are available updates. I would like to combine the functionality, but I’ve only briefly looked at doing so.. and I don’t feel like doing it now.

If anyone has any other solutions, or perhaps an official program with the same functionality I’d love to hear about it.

/etc/cron.weekly/check-update.sh – revision #1

#!/bin/bash
#
# Weekly check-update report
#
usr/bin/yum check-update > /tmp/.check-update
cat /tmp/.check-update | mail -s "Errata Report for $(hostname)" admin@example.com

/etc/cron.weekly/check-update.sh – revision #2

#!/bin/bash
#
# Weekly check-update report
#
MESSAGE=$(/usr/bin/yum check-update)
if [ $? -eq 100 ]; then
echo ${MESSAGE} | mail -s "Errata Report for $(hostname)" admin@example.com
fi

Email Notification of Available Updates: Ubuntu/Debian Server

February 21st, 2009 9 comments

At work we run a number of Red Hat Enterprise machines and CentOS servers.  After finding a large number of machines that were grossly outdated I decided to add a weekly cron job to notify us of available updates.  I used something along the lines of:

#!/bin/bash

yum check-update | mail -s “Weekly Errata Report for $(hostname)” admin@domain.tld

After dropping this little one-liner into /etc/cron.weekly/ we’re now notified of available package updates on a weekly basis, and our machines are keeping up to date much better!

I got to thinking this evening about how to achieve the same results on my Ubuntu and Debian servers.  There does not seem to be an equivalent command to ‘yum check-update‘, but there appears to be a similar solution.

#!/bin/bash

(apt-get update && apt-get -s safe-upgrade && apt-get -s full-upgrade) | mail -s “Weekly Errata Report for $(hostname)” admin@domain.tld

The apt-get equivalent command above is a bit more verbose but it basically does the same thing.  note: the parens are required so that the collective output of the three commands will be piped to the mail utility.

Does anyone else have any suggestions an how to accomplish this with standard Ubuntu/Debian tools?

Categories: Server Tags: , ,