Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I have access to a server running Ubuntu 12.04 LTS. I connect to it using XManager or PuTTY. But as soon as I close my client, I will be logged from the server. So is there a way how I could shut down my local machine and let the server compute for me.

I normally use the server for builds.

share|improve this question

marked as duplicate by Braiam, Eric Carvalho, Amith KK, Danatela, qbi Apr 21 at 12:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers 2

up vote 0 down vote accepted
sudo apt-get install screen
screen

You will now have a new console prompt. Anything you do in here will continue to run after your SSH session closes. When you reconnect with SSH later:

screen -dr

You are now reconnected to your screen session, which continued running while you were gone.

If you create more than one screen session, you'll get a list of all the screen sessions currently running when you do screen -dr as above - just do screen -dr pid (where pid is the pid number of the session you want to reconnect to) in order to choose one.

Typing exit while in a screen session will close the screen session for good, just as it would in a normal SSH or other console session.

share|improve this answer
add comment

You can run a process in the background by using an Ampersand (&). For example

sh example.sh &

would run the script example.sh in the background. You can then safely logoff and return later to check if the script has finished.

share|improve this answer
    
I have to give that in the shell right? Even my shell exits when I close my PuTTY –  GeekFactory Nov 22 '12 at 15:12
    
Yes you have to input that into the shell. Your shell needs to exit as soon as you close your client, because by exiting the client you're closing the connection to the server. –  fotomonster Nov 22 '12 at 15:29
    
@fotomonster this wont work. The prozess still would be bound on the specific shell and dies when this is closed. What you seem to search is "screen" gnu.org/software/screen/manual/screen.html Also "nohup" would fit. –  seta Nov 22 '12 at 16:30
    
Nohup does work - but you need to do nohup *command* &, complete with trailing ampersand, for it to work. Also: screen is almost always a better solution for this kind of thing. Details for usage in an answer below, in case the manpage is a bit too chewy to get you started (I avoided screen for far too long for exactly that reason; I wish somebody had explained it to me simply!) –  Jim Salter Nov 22 '12 at 17:18
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.