You need to run a one-off data fix against production through a Python script. How do you make it safe?
AdvancedScenarioAutomation scripting & CLI design
Answer
Situation read → One-off scripts skip review and testing, and touch production directly.
What I'd do →
- Code review the script like any change; check it into the repo under
oneoff/with a ticket reference. - Dry-run mode that prints exactly what will change, with counts, and a hard cap (
--max-items). - Back up or snapshot affected data first.
- Run in a controlled environment (bastion or CI job with an audited role), with output captured.
- Pair with a second engineer during the run; verify after.
Why → One-off scripts cause a disproportionate share of incidents because they bypass normal controls.
Interview tip → "Peer review plus dry-run plus backup plus cap" is the four-part answer.
More on Automation scripting & CLI design
Your team has a 300-line Bash script that parses JSON with `jq`, loops over AWS accounts and retries with `sleep`. It breaks every month. Do you rewrite it in Python?BeginnerA colleague's script deletes files older than 30 days from `/var/log/app`. You are asked to review it before it goes into cron. What do you look for?IntermediateYou need a script that ops engineers run from laptops and that CI runs nightly. How do you design its interface?IntermediateA script reads a 15 GB access log to count 5xx errors per endpoint, and the box runs out of memory. How do you fix it?BeginnerYou must run the same Python automation on 40 servers that have Python 3.6, 3.9 and 3.12. What do you do?IntermediateA cron job that runs a Python script fails silently. Nobody noticed for two weeks. How do you make sure that never happens again?Intermediate