You are adding a new scheduled job on Ubuntu 24.04 servers. Cron or a systemd timer?
BeginnerScenarioScenarios: text processing and scheduling decisions
Answer
Situation read → Both work; timers give more operational features on systemd hosts.
What I'd do →
- Choose a systemd timer by default: logs in the journal,
systemctl list-timersfor next/last run,Persistent=truefor missed runs, no overlapping runs,RandomizedDelaySec=, sandboxing,OnFailure=alerting. - Choose cron when the job must be portable to non-systemd systems or containers, or the team manages crontabs centrally and the job is trivial.
- Either way: absolute paths, locking, timeouts, and logs.
Why → Timers solve most of the classic cron pain (environment surprises, silent failures, overlaps) out of the box.
Interview tip → Name three concrete timer advantages; "it's newer" is not an answer.
More on Scenarios: text processing and scheduling decisions
Users report errors in the last hour. From the Nginx access log, find which endpoints produce the most 5xx responses.BeginnerA MySQL slow log is 3 GB. You need the 10 slowest query patterns. What do you do?IntermediateTwo servers that should be identical behave differently. Compare their installed packages.BeginnerFind which pods were OOMKilled in a namespace, with their container names and restart counts.IntermediateProduce a CSV of running EC2 instances that are missing an `Owner` tag.IntermediateYou have access logs from five web servers and need one timeline sorted by time. How?Intermediate