A scheduled report job sometimes runs for hours and piles up. It must be killed if it exceeds one hour. How?
BeginnerScenarioScenarios: text processing and scheduling decisions
Answer
Situation read → Enforce a hard limit at the scheduler level and handle the timeout clearly.
What I'd do →
- systemd:
TimeoutStartSec=1hin aType=oneshotservice; systemd sendsSIGTERM, thenSIGKILLafterTimeoutStopSec, and marks the run failed (Failed with result 'timeout'). - cron:
flock -n /run/lock/report.lock timeout -k 60 1h /opt/jobs/report.sh. - In the script, trap
TERMto clean up partial output. - Alert on timeouts separately from errors, and investigate why it got slow.
Why → A hard limit stops runaway jobs from stacking up and exhausting resources.
Interview tip → Mention timeout's exit code 124 so the wrapper can report "timed out" accurately.
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