LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-01-2007, 06:15 AM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
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
 
Old 11-01-2007, 12:43 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If ICMP is allowed you could 'ping -W 30 -c 1 servername || ssh anotherservername', if it doesn't maybe try 'ssh-keyscan -v -T 30 -t dsa servername >/dev/null 2>&1 || ssh anotherservername'? If that's not what you want maybe post the script?
 
Old 11-02-2007, 02:13 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try here (specifically TimerOn) : http://tldp.org/LDP/abs/html/internalvariables.html
 
Old 11-06-2007, 10:26 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
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



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script to sftp file to remote server OzTEXS Linux - Newbie 6 06-23-2013 05:33 PM
cronjob --> my script to scp to remote server bskrakes Linux - General 5 07-04-2007 04:25 PM
FTP files to remote server with a shell script Pezzoni Linux - Software 2 06-27-2007 07:01 AM
Cannot run shell script on the remote server haresh_dba Linux - General 2 04-14-2007 09:26 AM
Is there a way to easily shutdown a remote linux server with a shell script? bdb4269 Programming 7 01-26-2007 04:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration