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

kobemtl

Member
Nov 25, 2020
13
1
23
36
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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!