Apt-get exit for update

I wrote a script to update the ubuntu packages and to send me an email, however, the output of what was updated and restarted the services is not sent by email or not made. I tried to start the update from the command line and output it to a text file, but nothing is 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 
+4
source share
1 answer

Just using '&>' redirection in your apt-get commands will fix this problem.

 apt-get update &>$TEMP apt-get upgrade --assume-yes &>> $TEMP 
+4
source

All Articles