Q: You need to find all `.log` files modified in the last 7 days and copy them to an archive directory. What command do you use?
The most efficient command would be:
#Linux #Linux / SRE — Scenario-Based Interview Questions #L1 #SRE #Systems #Troubleshooting
🎙️ Candidate Opening & Architectural Context
""In an interview, I explain my systematic Linux troubleshooting methodology using Brendan Gregg's USE method. The interviewer is testing: Familiarity with `find` and `xargs` or `-exec`.. 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
The most efficient command would be: find /path/to/search -name "*.log" -mtime -7 -type f -exec cp {} /path/to/archive/ \; Alternatively, for a large number of files (to avoid spawning multiple cp processes), use xargs: find /path/to/search -name "*.log" -mtime -7 -type f -print0 | xargs -0 -I {} cp {} /path/to/archive/ The -mtime -7 checks for files modified in less than 7 days, -type f restricts to files only, and -print0 with -0 handles filenames with spaces safely.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: The most efficient command would be:."
⚡ 60-Second Elevator Pitch Talking Points
- Immediate Triage: The most efficient command would be:
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Advertisement