Solved

SSH Logout and reload session with running applications

Posted on 2004-09-13
8
952 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now