LinuxQuestions.org
Visit Jeremy's Blog.
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-24-2008, 03:51 PM   #1
aarontwc
Member
 
Registered: Oct 2008
Posts: 66

Rep: Reputation: 15
SSH timeout


Basically, i have a program that calls a program on a remote host via SSH in the background. In the command similar to the following:
ssh <remote-host-ip> <remote-program> &

But the problem is, this program stays infinitely in the background. Is there any method of implementation so that I can kill it? like after 10 seconds of trying?

I am trying to refrain from using TCPKeepAlive or sshd_config stuffs configurations. I was thinking of a fork() implementation where the parent sleeps for 10 seconds and then, if the child still haven responds to it, kill it.

Any better approaches?

Thanks
aaron
 
Old 11-24-2008, 04:19 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Do you have an exit statement at the end of the remote program?
 
Old 11-24-2008, 04:19 PM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
[Accidental double post]

Last edited by billymayday; 11-24-2008 at 04:33 PM.
 
Old 11-24-2008, 04:28 PM   #4
aarontwc
Member
 
Registered: Oct 2008
Posts: 66

Original Poster
Rep: Reputation: 15
Yes I do have.

But you see, the problem is in the event that there is a sudden lost in network connectivity. The SSH request just get left hanging there.. becuase it can't seem to communicate with the remote program.



Thanks
 
Old 11-24-2008, 04:42 PM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I haven't tried it, but have you thought about using ServerAliveInterval as an option at call time? Something like:

Code:
ssh <remote-host-ip> -o ServerAliveInterval 10 <remote-program> &
You don't mention if you tried TCPKeepAlive as a call option or config.
 
  


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
SSH Timeout shan_nathan Linux - Security 3 11-19-2007 06:48 AM
ssh getting timeout akash12 Linux - Networking 7 08-23-2007 09:01 AM
SSH timeout not anywhere OpenSourcePaul Linux - Server 2 03-16-2007 04:03 PM
SSH Timeout Swakoo Linux - General 4 04-17-2006 03:48 AM
why ssh timeout? sherifff Linux - Networking 1 05-06-2004 09:30 PM

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

All times are GMT -5. The time now is 10:03 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