Setting a Timeout

Hi

I'm writing a script which based on a condition, restarts a set of servers. The problem I'm facing is, say if one of the server is down, my script stops there and fails to proceed. How can I ensure to set a timeout value on that script, so when the server is not reachable, the script should skip that and proceed with the next?

ssh -o StrictHostKeyChecking=no user1@server1 shutdown -r
ssh -o StrictHostKeyChecking=no user1@server2 shutdown -r
ssh -o StrictHostKeyChecking=no user1@server3 shutdown -r

So, if server 2 is down, my script doesn't restart server 3. Any help?

---------- Post updated at 07:23 AM ---------- Previous update was at 06:18 AM ----------

Found the answer myself!

Looks like I need to add this:

ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 user1@server1 shutdown -r

Hi.

If you wish to run them in parallel, consider:

kanif - cluster management and administration swiss army knife
pdsh - Efficient rsh-like utility, for using hosts in parallel

among others.

Best wishes ... cheers, drl

1 Like

Thanks drl, I'll be sure to try them out!