Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SSH Logout and reload session with running applications

Posted on 2004-09-13
8
Medium Priority
?
960 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

730 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