Stop your cron tasks from disappearing into the black hole of stdout
Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop your cron tasks from disappearing into the black hole of stdout
🧩 The Challenge
You finally realize your cron job has been failing silently for three weeks because the output is just being swallowed by the void. It is infuriating to hunt for logs that don’t exist because cron assumed you didn’t care about the command’s exit stream.
💡 The Fix
Just redirect your stdout and stderr explicitly to a dedicated log file inside the crontab line. This way, you actually have a paper trail when things go sideways at 3 AM.
* * * * * /usr/local/bin/backup_script.sh >> /var/log/my_app_cron.log 2>&1
⚙️ Why It Works
Adding the 2>&1 bit forces the error stream to follow the standard output stream into your log file, preventing errors from being quietly dropped.
🚀 Pro-Tip: Use the date command inside your log path if you want to rotate logs daily without writing a complex logrotate config.
Linux Tips & Tricks | © ngelinux.com | 12/4/2026
