nixCraft Linux Forum

nixCraft

Linux / UNIX 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

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2007, 04:45 PM
Member
User
 
Join Date: Oct 2007
OS: Linux RHEL 5
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
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
  #2 (permalink)  
Old 06-11-2007, 08:56 PM
Member
User
 
Join Date: Oct 2007
OS: Linux RHEL 5
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
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, 03:47 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
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 Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


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 Off


Similar Threads

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


All times are GMT +5.5. The time now is 11:42 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

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 37 38