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!


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.

  • 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.


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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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