Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm newby so the question is simple. After I connected to server via putty I want to execute some command. Suppose that command will be performed for long time (e.g. extracting files from large archive or mysql backup). Is there a way to execute a command in such a way that it wount be aborted after I close putty!

thank you in advance!

share|improve this question
up vote 10 down vote accepted

The best way is to run screen, execute your command, then detach using ^A, D. When you ssh into your machine again, run screen -r and your session will be reattached just as you left it. Screen can also do much more, check out the man page to see what's possible.

share|improve this answer
Prefer tmux, but much the same idea. – 84104 Jun 17 '11 at 20:32

There's a package called "screen" that needs to be installed on the host you're logged into. This has nothing to do with putty, or ssh - this is the way Unix shells work. When you disconnect a shell, you're logged off, and all your processes get a HUP signal. Most (all) processes shut down. "Screen" makes your shell continue running, so you may reconnect later.

share|improve this answer

Yes! You should background the process and disown it.

So, if I wanted to run the command "foo", I'd do nohup foo & && disown. The nohup keeps it from dying when SIGHUP is sent to it and sends the output to a file, and disown removes the parent reference so it doesn't die when the spawning shell does.

share|improve this answer
This will work as well, although you won't be able to interact with it and hopefully can get everything you need out of the logfile. – mfinni Jun 17 '11 at 16:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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