I wrote a script that runs on multiple servers. Sometimes the script gets hung on one of the servers and I have to hit (control C) to end the process. If not, it gets stuck and keeps trying to connect.
If/when a server gets hung or unresponsive when running a script, is there a way to skip that host so the script can go to the next host and keep running along? Usually When I hit control C, that ends the entire process.
Here's an example of the script. Let's say it gets hung on machine 3.
HOSTS=(MACHINE1 MACHINE2 MACHINE3 MACHINE4 MACHINE5)
for i in "${HOSTS[@]}"
do
echo "$i"
ssh -q "$i" uname -a
done
This script is being run on OS X. I tried using the timeout
command but unfortunately, it does not work.
for i in "${HOSTS[@]}" do echo "$i" ssh -q "$i" uname -a done
– Sad Puppy Aug 27 '15 at 20:25