Output apt-get upgrade to text

apt-get, bash, ubuntu

Solution

Just using '&>' redirect in your apt-get commands would fix this issue.

apt-get update &>$TEMP
apt-get upgrade --assume-yes &>> $TEMP

Problem

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="user@example.com" cat /dev/null > $TEMP apt-get update && apt-get upgrade --assume-yes > $TEMP mail -s "Upgrade for $HOSTNAME" $MAIL_ADDR < $TEMP rm $TEMP ```

Original source