Interview Prep/Linux/Scheduling, automation and scripting

You need to run the same command on 40 servers right now and you don't have Ansible set up. What do you do?

IntermediateScenarioScheduling, automation and scripting
Answer

Situation read → Parallel SSH, carefully.

What I'd do →

# hosts.txt has one host per line
parallel-ssh -h hosts.txt -i -t 30 'uptime'           # pssh package
# or plain bash + xargs
xargs -P 10 -I{} ssh -o BatchMode=yes -o ConnectTimeout=5 {} 'uptime' < hosts.txt

Run on one host first, then a small batch, then the rest.

Why → BatchMode=yes stops it hanging on password prompts; limiting parallelism avoids overloading shared services.

Interview tip → Say you'd move it into an Ansible ad-hoc command (ansible all -m shell -a uptime) as soon as possible.

All Linux questions Roadmap: Linux

More on Scheduling, automation and scripting