LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-24-2006, 08:18 AM   #1
briel
LQ Newbie
 
Registered: Oct 2006
Posts: 1

Rep: Reputation: 0
SSH disconnect, connect to process


I've been thinking about how to recover from a remote SSH disconnect, when the process is still present until the system automatically kills it. For example, if I am in my editor in SSH remotely, and I am disconnected for one of various reasons, and then I reconnect to the same host and see that there is a process present with my editor up and running in it (for a period of time). Since I am logged in again as the same user, could there be a way to reconnect to that "hanging" process before it is auto-killed, and gracefully save my changes?
CB
 
Old 11-24-2006, 03:19 PM   #2
meetscott
Samhain Slackbuild Maintainer
 
Registered: Sep 2004
Location: Phoenix, AZ, USA
Distribution: Slackware
Posts: 410

Rep: Reputation: 42
The server ususally drops the connection when there is no activity. One way I keep connections going, is when I'm tailing a log file. This works for active log files. If there is nothing coming into the logs then it will drop eventually.

I wonder if you couldn't run a batch job in the back ground with a "sleep" function in there just to generate some activity so you remain connected. Make it like "sleep 300", for 5 minutes. Then keep executing some function that's benign like "uptime" that would output to the console once in a while. Hmmm. You got me thinking about how to keep the connection going

Don't know a way to reconnect though. I will watch this thread and see if someone else has an idea.
 
Old 11-24-2006, 04:32 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Consider running your editor in screen (if it's installed on the remote machine). You can re-connect to screen after you log back in.

Failing that, you might try to trap signals which are sent to your shell by the server. I would imagine it will send SIGHUP or SIGTERM to the login shell when it wants to auto-disconnect you. If it sends SIGKILL, there's nothing you can do, but maybe not. You could try this, but bare in mind you may well get the sysadmin chasing you with a scimitar for doing this...

Alter your .bash_profile (or if you are using a different shell, whatever file is executed on login):
Code:
function nokillme () {
    echo "ignoring signal - hahaha" > /dev/null
}

trap nokillme HUP INT TERM QUIT
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH on LAN - server disconnect geek745 Linux - Networking 13 02-28-2006 04:28 PM
auto detect disconnect / connect vb7prog Linux - Networking 1 11-18-2004 03:26 AM
how do i connect to the internet without becoming su, and disconnect afterwards? Quercus ruber Linux - Newbie 7 07-30-2004 03:07 PM
Keeping a process running after disconnect steyr Linux - General 2 02-25-2004 06:03 AM
How to connect or disconnect adsl Mimicafe Linux - Networking 4 03-07-2003 10:48 AM


All times are GMT -5. The time now is 05:21 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration