Solved

SSH Logout and reload session with running applications

Posted on 2004-09-13
8
955 Views
Last Modified: 2012-05-05
Sorry if the title is a bit ambiguious, but here goes:

I currently have an application running on a remote server which I want to keep running after I logout via SSH.  I would then like to be able to log back into the machine at any time and see if this application is still running.  I don't know whether it is possible, but to go back into the session I had before so that I can stop or restart the application and use the front end without having to restart it (currently done by killing the open process)

Is it possible to do it this way or would I need to put the application in the background then bring it to the foreground when I want to regain access to it?

I really haven't got a clue and would be grateful for some help, thanks.

Garry
0
Comment
Question by:garry_m
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 50 total points
ID: 12042119
Not exaclty sure what you need, but take a look at screen:
http://www.gnu.org/software/screen/
and
http://frogcircus.org/screen/ssh-agent
0
 
LVL 3

Expert Comment

by:pat5star
ID: 12042253
I'm mostly just posting here so I get emailed when someone else answers. I'm interested in this question as well.

This is my understanding: If you SSH into a machine, start a process, send it to the background, then log out, you are unable to 'reattach' to that process when you log back in again. You either have to stay logged in so you can bg/fg the process, or if you choose to log out and log in again later, you will have to use top/ps to find out whether it's running or not, and to end it early you will have to use kill. You won't be able to pause and restart it again.

I sure would like to be wrong on this.

-Pat



0
 
LVL 18

Expert Comment

by:liddler
ID: 12042581
Pat,
You don't need to post to get emails for a Question, just click on the subscribe link, near the bottom of the Q.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 3

Expert Comment

by:pat5star
ID: 12042604
liddler,

Cool, I didn't realize that. Thanks :)

-Pat
0
 
LVL 20

Assisted Solution

by:Gns
Gns earned 50 total points
ID: 12042778
... And Pat, liddler is quite right. Run the process you'd like to "attach/detach" to under a screen session and you'll be able to do just that. For a plain shell "session" it'd hold true that by ending the session, you'd return the terminal... and have no way of regaining it... Screen overcomes this nicely:-). In it just <Ctrl>-<a><d> to detach from the session/window, then later on just "screen -list" to see what's there to attach to, and "screen -r [if more than one session, perhaps specify the PID.TTY.HOST triple]" to reattach...
Liddlers second link above show an outline as for how to "automate" the process a bit (using ssh-agent). Very nice any way you use it:-).
And best of all, almost all distros carry screen by default, and most install it in the default setup.
man screen
would be a next logical step:-)

-- Glenn
--
0
 
LVL 1

Expert Comment

by:HollyRidge
ID: 12044598
Screen is a wonderful program on linux servers and will allow you most of the time to get back into a current session. You would just "x" out of the ssh window instead of using the exit command. Once you log back in run the command...

screen -ls

That will give you the list of sessions. You would then run the following command (substitute sessionhere for the actual session you want to get back to.)...

screen -dr sessionhere


Now another option you may have here is running your application into memory is to use the && after it such as...

./applicationfile&&
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question