Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Linux - Cron - How ...
 
Share:
Notifications
Clear all

[Solved] Linux - Cron - How to disable email notifications from crontab (Proxmox)

2 Posts
1 Users
0 Reactions
453 Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
Topic starter  

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.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2728
Topic starter  

Some more Proxmox fun, with these scripts (CPU temperatures, no Nag etc):

https://github.com/Meliox/PVE-mods


   
ReplyQuote
Share: