Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop cron from nuking your mail server with local error logs
đź§© The Challenge
You know that feeling when you check your server logs and realize cron has been frantically trying to send you thousands of “command not found” emails because one minor script had a typo? It’s a fast way to fill up an inbox and drive your mail transport agent into a complete meltdown.
đź’ˇ The Fix
Redirect all that useless noise directly into /dev/null unless you actually want to be spammed. Just append a standard redirection to the end of your crontab lines to keep your logs clean.
* * * * * /usr/local/bin/my-script.sh > /dev/null 2>&1
⚙️ Why It Works
By sending both standard output and standard error to the null device, you’re essentially telling cron that if the command is silent, the success is assumed and the failure shouldn’t trigger an email notification. It saves you the headache of manually purging the local mail spool later.
🚀 Pro-Tip: If you actually need to debug a job, change the redirect to a specific log file instead of /dev/null so you can see what’s breaking without triggering the mailer.
Linux Tips & Tricks | © ngelinux.com | 7/31/2026
