nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

script hangs when a remote server is down

This is a discussion on script hangs when a remote server is down within the Shell scripting forums, part of the Development/Scripting category; Hi all, I have made a script which logins to remote servers and fetches some data from it. Is is ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 11-01-2007, 05:45 PM
Member
User
 
Join Date: Oct 2007
My distro: Linux RHEL 5
Posts: 33
Rep Power: 0
vikas027 is on a distinguished road
Question script hangs when a remote server is down

Hi all,

I have made a script which logins to remote servers and fetches some data from it.
Is is working perfectly when all servers are reachable
BUT
my problem is -- if in case a server is down (or not reachable), the script hangs.

Is there some way, that the script just continues to ssh another server when a particular server is not responding say for 30 sec.

I am using ssh to login into servers and have used ssh-keygen command to bypass passwords.

Pls help, just finalizing the script.

Thanks in adv.

Regards,
Vikas
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-06-2007, 09:56 PM
Member
User
 
Join Date: Oct 2007
My distro: Linux RHEL 5
Posts: 33
Rep Power: 0
vikas027 is on a distinguished road
Smile

Hi all,

Thanks for your co-operation.


I was looking something like this :--


Quote:
ping -c 1 -w 180 192.168.1.4 1>/dev/null 2>/dev/null

This will wait for 3 mins, if the machine is up, it will return '0'.

Check the return state of the above command and run ssh it the return value is '0'.
Thanks to all.

Regards,
Vikas
Reply With Quote
  #3 (permalink)  
Old 11-11-2007, 04:47 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Hello,

SSH client will disconnect automatically when remote box is down, you don't need any special logic. Can paste your script so that I can take a look at it
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Remote access to linux server RamPD Linux software 9 05-26-2008 08:21 AM
Fail to mount remote NFS server satimis Web servers 0 04-19-2008 09:06 PM
Shell script to perform operation on remote server vivekv Shell scripting 3 10-24-2007 01:10 AM
How to recover if server crash in remote? kitty@sad Solaris/OpenSolaris 1 02-27-2007 10:02 PM
remote server monitoring for Solaris pliu0606 Solaris/OpenSolaris 4 10-15-2005 03:49 PM


All times are GMT +5.5. The time now is 07:47 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36