ssh timeout

Ben Kevan ben.kevan at gmail.com
Fri Sep 25 08:51:59 UTC 2009


On Fri, 25 Sep 2009 02:16:34 -0000, <nitin.gizare at wipro.com> wrote:

> HI
>
>
> I am running script using ssh to capture load of some parameters of
> remote machine.
>
> But if one of machine is down script does not go forward and will be
> waiting for to come up and complete ssh connections.
>
> I would like to set some time out in which case if machine does not
> response it should time out on ssh and proceed for next steps.
>
>
> Please help me with this settings
>
>
> Rgds
>
> Nitin
>


I think everyone missed his point.. he didn't want ssh timeouts.. the  
original request is:

"But if one of machine is down"

So what you want is to do a ping to the machine, if ping fails then don't  
run the script:

ping -c 1 -w 1 $SERV 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
	Run the code you want to run
else
	echo "$SERV is not up"
fi


-- 
If you don't know what you want, you end up with a lot you don't.  -Fight  
Club




More information about the redhat-sysadmin-list mailing list