Grimlockz
Grimlockz

Reputation: 2581

Output apt-get upgrade to text

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

Answers (1)

n3rV3
n3rV3

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

Related Questions