[SOLVED] Help: Host backup cronjob email only error occur

kobemtl

Member
Nov 25, 2020
17
1
23
37
I am using proxmox-backup-client to backup my PVE nodes. Everything works fine. Problem is when I put that in cronjob, even I am using > /dev/null, I am getting the output. Since I setup postfix on the nodes, I am getting email all the time. Is it anyway I can get email only when error occur? Thanks.
 
how does your backup-client command look exactly? redirecting stdout to /dev/null should not generate any output if the backup was successful (thus cron should not send an email)
 
quick and dirty shell scripting:

(cmd > /tmp/backup.log 2>&1 || cat /tmp/backup.log) && rm /tmp/backup.log

saves the whole output to /tmp/backup.log (stdout & stderr), and prints it when the exit code of the command is != 0, then removes the file
 
Thank you for the reply.

I will try that out. It will be nice to have of kind of quite mode for the backup client.