- Learnwithdevopsengineer
- Posts
- ⚠️ It Works in Terminal... But Cron Fails Quietly
⚠️ It Works in Terminal... But Cron Fails Quietly
A real Linux failure you can reproduce — and the 3-line fix that makes Cron jobs reliable.
When Your Cron Job Runs… But Does Nothing
Alright, tell me if this has ever happened to you. You set up a cron job, it looks perfect, you wait a minute… nothing. No output, no logs, no errors. Just silence.
That’s exactly the failure we recreated in my latest Linux simulation.
What Happened
I built a small backup script. When I ran it manually, everything worked fine — data archived, backups created.
But when cron ran the same script? It failed silently.
The Debugging
Here’s the catch: cron is not your shell.
It doesn’t load
.bashrc
or.zshrc
It runs with a minimal
PATH
And it executes from a different working directory
So relative paths like ./app/do_backup.sh
broke instantly.
📩 Want 23 more real-world DevOps failures like this — with scripts you can actually run?
👉 Subscribe to my newsletter here
📂 Takeaway Code Snippet
❌ Failing entry
* * * * * bash ./app/do_backup.sh >> logs/cron.log 2>&1
✅ Fixed entry
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
* * * * * cd /absolute/path/to/project && /usr/bin/env bash app/do_backup.sh >> logs/cron.log 2>&1
Just three small guardrails — SHELL, PATH, and cd — make cron behave like your terminal.
▶️ Full Walkthrough
👉 I recorded the entire failure + fix step by step. Watch it here: https://youtu.be/gNs-1WjlImU
Why It Matters
Cron powers critical jobs — backups, cleanups, reports.
One wrong path, and you might be missing backups for weeks without realizing it.
This demo shows you exactly how to avoid that trap.
👋 Final Note
If you enjoyed this breakdown, hit subscribe to this newsletter.
Every week I share real DevOps failures you can actually reproduce — so you never get caught off guard in production.
— Arbaz
📺 YouTube: Learn with DevOps Engineer
📬 Newsletter: learnwithdevopsengineer.beehiiv.com/subscribe