[clug] Debian: automate apt-get update

Tony Breeds tony at bakeyournoodle.com
Wed Mar 29 06:16:48 GMT 2006

On Wed, Mar 29, 2006 at 02:51:53PM +1000, Greg wrote:
> Hi debian/ubuntu users,
> Just wanted to grab some opinions on the best way to automate
> downloading security updates.  I want to get the security updates,
> dist-upgrades I will handle manually.  I have seen talk of cron-apt and
> wonder if people use it and what they think of it?  Does it beat a
> cronjob like:
> apt-get update && apt-get -y -u upgrade >> /var/log/my_updates
> Basically I have a box that runs an ssh server (and not much else) and
> want to be sure I grab security updates automatically.

I run:

/usr/bin/apt-get -q2 update
/usr/bin/apt-get -q2 dist-upgrade -d
/usr/bin/apt-get -q2 autoclean
MSG=$( /bin/echo 'n' | /usr/bin/apt-get dist-upgrade -ud 2>&1 | /bin/egrep '^[ T]' 2>/dev/null )

if [ -n "$MSG" ] ; then
        /bin/echo "$MSG" | mail -s "$(/bin/hostname) packages to update $( /bin/date +"%Y-%m-%d" )" tony at localhost >/dev/null 2>&1

from cron nightly (well 02:00am localtime)

This will download everything I need and email me it there is stuff

You could add a "set -e" if you want it to abort automatically if
anything goes wrong.

Yours Tony

   linux.conf.au       http://linux.conf.au/ || http://lca2006.linux.org.au/
   Jan 23-28 2006      The Australian Linux Technical Conference!

More information about the linux mailing list