Stop cron from sending you empty emails every time a job runs

Cron & Task Scheduling (Cron/Systemd Timers/At)

Stop cron from sending you empty emails every time a job runs

🧩 The Challenge

Setting up a quick cron job is great until your mail server starts choking on thousands of empty messages. I’ve spent way too much time cleaning out /var/spool/mail because of silent scripts that spit out just enough output to trigger the mailer daemon.

💡 The Fix

You can just redirect both standard output and standard error to /dev/null to silence the job entirely. But if you actually want to know when things go sideways, just redirect the output to a log file instead.

* * * * * /usr/local/bin/backup-script.sh > /var/log/backup.log 2>&1

⚙️ Why It Works

Adding that 2>&1 bit forces your error stream into the standard output stream, meaning everything lands in one file and cron doesn’t see a reason to alert you. When you forget this, the mailer interprets even the smallest bit of debug text as a successful completion note that it needs to deliver.

🚀 Pro-Tip: If you only want errors and not the noise, use > /dev/null 2>> /var/log/script_errors.log to keep your main logs clean.

Linux Tips & Tricks | © ngelinux.com | 7/27/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted