Here’s a quick script you can put in your cron rotation to check and see if there are any updates available and what they are:
#!/bin/bash
yum_output=/tmp/yum-check-update-output.txt
python=/usr/bin/python1.5
yum=/usr/bin/yum
$python $yum check-update > $yum_output
yum_return_code="$?"
case $yum_return_code in
100)
# Packages available for update.
echo '********************************************************'
echo "The following packages need to be udpated on $HOSTNAME"
echo '********************************************************'
echo ''
cat $yum_output
;;
0)
# No packages available for update.
;;
*)
echo "YUM: Undefined return code: $yum_return_code ."
exit 1
esac
exit 0
what would you change to make this work for apt? And is it possible to have it send an email? just pondering
Well that depends on what kind of return codes apt has. Yum will return “100″ if there are packages to be updated and “0″ if not.
Typically in /etc/crontab you can set where ou want any output from scripts to go to; usually it is set to go to “root”, so it will mail it’s output out, but yes you could pipe the output to “mail” or “sendmail” and mail it off that way.
hmm interesting. ill have to try setting that up. cool script though, thanks.