Don’t let your cron jobs mail you to death
Cron & Task Scheduling (Cron/Systemd Timers/At)
Don’t let your cron jobs mail you to death
🧩 The Challenge
You finally fixed that backup script that was failing, but now you have ten thousand unread messages in /var/spool/mail/root. Every time the script runs, it spits out a single character to stdout and cron tries to be helpful by mailing you the result.
💡 The Fix
Just tell cron to send that output straight to /dev/null by appending the right redirect symbols. It keeps your mail spool clean and stops your inbox from filling up with useless noise.
* * * * * /usr/local/bin/backup-script.sh > /dev/null 2>&1
⚙️ Why It Works
Redirecting both standard output and standard error to the null device ensures cron has nothing to capture or send. Without that 2>&1, you’ll still get an email every time there’s a minor error.
🚀 Pro-Tip: Use MAILTO=”” at the top of your crontab file to disable mail alerts for the entire file globally.
Linux Tips & Tricks | © ngelinux.com | 10/22/2026
