Stop your cron jobs from failing silently and driving you nuts
Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop your cron jobs from failing silently and driving you nuts
🧩 The Challenge
You’ve got a cron job, it’s configured, but nothing seems to be happening. No emails, no log output you can see, just… silence. And you sit there wondering if it even ran, or if it blew up, or if the server fairies ate it. It’s infuriating trying to debug something that gives you zero feedback.
💡 The Fix
Tell your cron job to explicitly log its start and end to syslog. This way, you get a timestamped entry that says, “Hey, I started!” and “Hey, I finished!” You’ll know if cron even bothered to kick it off, and if your script completed.
0 2 * * * /usr/bin/logger -t MY_CRON_JOB "Starting my_script.sh" && /path/to/my_script.sh && /usr/bin/logger -t MY_CRON_JOB "Finished my_script.sh successfully" || /usr/bin/logger -t MY_CRON_JOB "my_script.sh FAILED"
⚙️ Why It Works
`logger` sends messages to the system syslog daemon, usually `rsyslog` or `systemd-journald`. Using the `-t` flag gives you a tag to easily grep for in your logs. And by chaining the commands with `&&` and `||`, you’re sending a “started”, “finished”, or “failed” message based on the script’s exit code.
🚀 Pro-Tip: Combine this with `2>&1 | /usr/bin/logger -t MY_CRON_JOB -s` inside your script to send its actual stdout/stderr to syslog *and* the console for immediate debugging.
Linux Tips & Tricks | © ngelinux.com | 11/20/2026
