Stop cron from sending you empty emails every time it runs
Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop cron from sending you empty emails every time it runs
🧩 The Challenge
You’ve set up a cron job to keep a database index optimized, but now your inbox is flooded with useless “task completed” emails every hour. It’s an easy way to miss actual errors when they finally pop up.
💡 The Fix
Redirect both standard output and standard error to null for silent jobs, or redirect to a log file if you only want to check the history when things break.
0 * * * * /usr/local/bin/optimize-db.sh > /dev/null 2>&1
⚙️ Why It Works
Adding the redirect forces the shell to drop all output, keeping your mail spool clean and preventing cron from trying to spawn a local mail command for every run.
🚀 Pro-Tip: Use &> /dev/null if you’re on a modern bash version to save a few keystrokes.
Linux Tips & Tricks | © ngelinux.com | 11/9/2026
