Stop cron jobs from burying your mailbox in alerts
Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop cron jobs from burying your mailbox in alerts
🧩 The Challenge
Dealing with a flooded local mailbox because your cron job spits out “File not found” every five minutes is a nightmare. I once spent an entire afternoon purging thousands of tiny mail files because I forgot to redirect the output.
💡 The Fix
Just tell cron to pipe the output to dev null or append it to a dedicated log file if you actually need to debug it later. It keeps your system clean and stops you from getting unnecessary notifications.
* * * * * /usr/local/bin/backup.sh > /var/log/backup.log 2>&1
⚙️ Why It Works
Adding the 2>&1 at the end tells the shell to send both standard output and standard error to the same location. It’s the easiest way to make sure nothing accidentally triggers the local mailer daemon.
🚀 Pro-Tip: If you need to keep logs but don’t want them filling the disk, point them at /dev/null or configure logrotate to sweep them up.
Linux Tips & Tricks | © ngelinux.com | 10/4/2026
