A Ubuntu automatic update script with email notifications.

We all know that we should keep our systems up to date with security patches and whatnot. This is something that we don't thing about on desktop computers, our operating systems (windows/ubuntu) do it automatically for us, giving us popup notifications when these are ready.

But on servers we never log in to get those notifications, as long as things keep running we don't care. You may get hacked one day and become extra vigilant for a while, but that's not going to last, were all lazy.

So in the spirit of "automate everything" I've made this script to check if there are any updates on my Ubuntu server and notify me to apply them, via email. I could have the updates install on their own but they've been known to break things, and i'd rather be ready to fix it than of climbing a hill unable to log in.

sudo apt-get update > /dev/null
CUPDATE=`sudo apt-get --download-only --yes dist-upgrade`
if echo $CUPDATE | grep 'The following packages will be upgraded' > /dev/null
        GmailSend.py -u me.machine@gmail.com -p ###### -t me@gmail.com -s "server:update" -b "$CUPDATE"
edit the email addresses & chuck that in ya crontab and your away.

Using GmailSend.py (by me) to give email notifications.