Reputation: 2581
I've written a script for updating ubuntu packages and to email me however the output of the what's been upgrade and services restarted does not get emailed or produced. I've tried to run the update from the command line and output to a text file but still nothing gets written to the text file. Any ideas?
TEMP="/tmp/upgrade.txt"
MAIL_ADDR="[email protected]"
cat /dev/null > $TEMP
apt-get update && apt-get upgrade --assume-yes > $TEMP
mail -s "Upgrade for $HOSTNAME" $MAIL_ADDR < $TEMP
rm $TEMP
Upvotes: 4
Views: 2648
Reputation: 1106
Just using '&>' redirect in your apt-get commands would fix this issue.
apt-get update &>$TEMP
apt-get upgrade --assume-yes &>> $TEMP
Upvotes: 5