Q: A legacy cron job runs every 5 minutes (`*/5 * * * *`). It takes 6 minutes to complete, so instances are overlapping, locking the database, and failing. The developer wants to migrate it to `systemd` timers. How does systemd solve this overlapping issue inherently?
Traditional cron is notoriously "dumb." It strictly fires by the clock regardless of the state of the previous job, requiring developers ...
#Linux #Linux / SRE — Scenario-Based Interview Questions #L2 #SRE #Systems #Troubleshooting
🎙️ Candidate Opening & Architectural Context
""We encountered this OS-level bottleneck during peak traffic and diagnosed it down to kernel and filesystem metrics. The interviewer is testing: Cron vs Systemd Timers, execution safety.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third.""
Advertisement
🛠️ Production Runbook & Step-by-Step Resolution
1️⃣
Production Solution & Architecture
Traditional cron is notoriously "dumb." It strictly fires by the clock regardless of the state of the previous job, requiring developers to write complex bash flock (file locking) wrappers to prevent overlap. Systemd Timers solve this intrinsically. When you migrate it to a service.timer unit, the default behavior of systemd is that it will not trigger the linked service unit if that specific service is already actively running. It mathematically protects against overlapping executions without needing a single line of locking code written by the developer.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Traditional cron is notoriously "dumb." It strictly fires by the clock regardless of the state of the previous job, requiring deve."
⚡ 60-Second Elevator Pitch Talking Points
- Immediate Triage: Traditional cron is notoriously "dumb." It strictly fires by the clock regardless of the state
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Advertisement