Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SSH Logout and reload session with running applications

Posted on 2004-09-13
8
Medium Priority
?
961 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
8 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

927 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