Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 10-24-2006, 09:18 AM   #1
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?
Old 11-24-2006, 04:19 PM   #2
Samhain Slackbuild Maintainer
Registered: Sep 2004
Location: Phoenix, AZ, USA
Distribution: Slackware
Posts: 411

Rep: Reputation: 43
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, 05:32 PM   #3
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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):
function nokillme () {
    echo "ignoring signal - hahaha" > /dev/null

trap nokillme HUP INT TERM QUIT


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 05:28 PM
auto detect disconnect / connect vb7prog Linux - Networking 1 11-18-2004 04:26 AM
how do i connect to the internet without becoming su, and disconnect afterwards? Quercus ruber Linux - Newbie 7 07-30-2004 04:07 PM
Keeping a process running after disconnect steyr Linux - General 2 02-25-2004 07:03 AM
How to connect or disconnect adsl Mimicafe Linux - Networking 4 03-07-2003 11:48 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:50 AM.

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