Source

mindref-sbin / apt-update

Full commit
#!/bin/bash
. /usr/local/sbin/func/random_sleep

#mailto=
mailto='debian-updates@dev.local'

random_sleep 600 60

# Download only; package files are only retrieved, not unpacked or
# installed.
apt-get -dqq update
apt-get -dyqq dist-upgrade

if [ -z $mailto ]; then
    #echo "Mail disabled."
    exit 0
fi

has_upgrades=$(apt-get -s dist-upgrade | grep ^Inst | sed 's/Inst //g')
if [ "$has_upgrades" ] ; then
    #echo "Sending updates report."
    echo "$has_upgrades" | mail -s \
        "Updates for $(hostname -s) on $(date +%Y-%m-%d)" \
        $mailto
fi