I'm running a backup shell script every night where i tar some data and then send it to a different server by sftp. As this is really important data i would like to get noticed by email if something goes wrong. Thats why i opted in to get notified if errors occur in the cron job (managed server).
This is how the sftp connection looks like:
sftp -i ~/.ssh/id_rsa server.com <<EOF
put $file
rm $file_old
EOF
Unfortunately right now i get a mail every time the script runs showing me the output of the sftp connection like this:
Connected to server.com.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
The script works and the files are transferred. So is there a way to hide the output of the sftp connection but yet show possible errors of the script. Any help is greatly appreciated!