how do i avoid system hang due to ssh in script?

I have a script that collects data from about 200 servers using 'ssh'. The problem is that, process sometime hangs at some point stopping the execution of the script. Please give me some idea how can I force the execution to jump to the next step if there arises any problem !! Thanks for replies if any :slight_smile:

You can try running your ssh command in the background and then follow it by a loop. The loop keeps running as long as it sees the ssh command in a 'ps -al' listing.

However, the loop needs to have some type of time counter (use a combination of 'sleep' and a general count variable), and when that expires, it grabs the process ID of the ssh command and kills it.