APT-Checker

This script is meant to be run from /etc/cron.daily/. It checks for available updated packages on a Debian system and sends a mail to the administrator.

#!/bin/sh
 
HOSTNAME="hostname"
MAILTO="admin@example.com"
MAILFROM="apt checker <admin@example.com>"
 
apt-get update >/dev/null 2>&1
 
NEWPACKAGES=`apt-get --print-uris -qq -y upgrade 2>/dev/null |awk '{print $2}'`
 
if [ "$NEWPACKAGES" != "" ]
then
  mail -a "From: $MAILFROM" -s "New Packages for $HOSTNAME" $MAILTO <<EOF
There are new Packages available for $HOSTNAME:
 
$NEWPACKAGES
 
please run:
  ssh root@$HOSTNAME 'apt-get upgrade'
 
EOF
fi
 
exit 0;
 
code/bash/aptchecker.sh.txt · Last modified: 2005/08/27 13:13 by bw
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki