So, running a little script to send temperature data from Proxmox to my Home Assistant caused a mild flood of emails as I did not realize that cron would send emails with each task it would run. Looking for an answer, I have seen that quite a few people run into this situation, and I have seen some colorful fixes.
So here what I have found and used ...
Short version: MAILTO=""
The short version is to add this line at the beginning of your crontab (see man page), these are the step for Proxmox:
Select "proxmox" and open a shell (through the WebUI).
Open crontab:
crontab -e
Add this line at the beginning of the crontab file:
MAILTO=""
Save the changes and close the text editor and restart the crontab service.
systemctl restart cron.service
systemctl status cron.service
Alternative - Send to NULL
You can of course redirect cron output to oblivion by appending this after a command.
>/dev/null 2>&1
Some examples:
0 1 5 10 * /path/to/script.sh >/dev/null 2>&1
0 1 5 10 * /path/to/script.sh > /dev/null
0 * * * * /path/to/command arg1 > /dev/null 2>&1 || true
0 30 * * * /root/bin/check-system-health.py > /dev/null
1 30 * * * /root/bin/some-job &> /path/to/some.app.log.file
## Append instead of overwriting the log file ##
1 30 * * * /root/bin/some-job &>> /path/to/some.app.log.file
2 45 * * * /root/bin/foo-job &> /dev/null
If you want to know more about this: look for redirecting stdout and stderr under Linux.