Site icon New Generation Enterprise Linux

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 `/var/spool/mail/root` file that has hit multi-gigabyte sizes because some half-baked script is printing standard output to the console every single minute is a nightmare. I once had a production server choke on I/O wait because of this exact scenario and it’s not how I wanted to spend my Friday night.

💡 The Fix

Just pipe the output of your scripts directly to /dev/null or append it to a dedicated log file if you actually need to debug things later. It keeps the local mail system clean and stops the inode usage from creeping up.

* * * * * /usr/local/bin/backup.sh > /dev/null 2>&1

⚙️ Why It Works

Redirection using 2>&1 forces the standard error to follow the standard output into the bit bucket, ensuring nothing ends up back in the local mail spool. It’s the most reliable way to keep your logs from becoming a black hole.

🚀 Pro-Tip: Use logger -t tagname inside your script instead to ship events directly to syslog instead of managing your own files.

Linux Tips & Tricks | © ngelinux.com | 8/21/2026

0 0 votes
Article Rating
Exit mobile version