Keep your cron logs from getting lost in the void
Cron & Task Scheduling (Cron/Systemd Timers/At)
Keep your cron logs from getting lost in the void
🧩 The Challenge
Setting up a cron job is easy until the task actually fails and you have no record of why it died. I’ve spent way too many mornings grepping through random system logs trying to find a silent script failure that happened at 3 AM.
💡 The Fix
Just redirect your stdout and stderr directly to a dedicated log file inside the crontab itself. It’s the fastest way to stop guessing what happened while you were sleeping.
* * * * * /usr/local/bin/my-script.sh >> /var/log/my-script.log 2>&1
⚙️ Why It Works
Adding that 2>&1 at the end tells the shell to pipe standard error into standard output, dumping everything into one file so you can actually read the error message. You’ll thank yourself when you see a clear python traceback instead of a generic job failure notification.
🚀 Pro-Tip: Throw a date command at the start of your script so you know exactly when each execution attempt hit the log.
Linux Tips & Tricks | © ngelinux.com | 10/11/2026
