Stop losing your sanity when cron jobs spit out hidden errors
Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop losing your sanity when cron jobs spit out hidden errors
🧩 The Challenge
Everyone thinks their cron jobs are running perfectly until they realize the database dump hasn’t actually touched the disk in three weeks. You check the system logs and see absolutely nothing because the output was just swallowed by the abyss of /dev/null.
💡 The Fix
Force your cron jobs to log their standard error and output to a specific file so you actually have something to read when things go south. It’s the difference between guessing what broke and fixing it in thirty seconds.
* * * * * /usr/local/bin/backup-script.sh >> /var/log/my_cron_job.log 2>&1
⚙️ Why It Works
Redirecting the file descriptor 2 to 1 merges stderr into stdout, ensuring that every single error message gets captured alongside your normal job output. Without that little 2>&1 bit, the system silently discards all those useful failure traces.
🚀 Pro-Tip: Use a dedicated logrotate config for these files unless you want your root partition to fill up with years of history.
Linux Tips & Tricks | © ngelinux.com | 10/29/2026
