There is a program that takes unexpectedly long to run. Before I started it, I did not start screen. So I dont know how to detach the process now. Is there any way to keep this process running on background even if I quit the current ssh session without killing it first?


The typical way to do this is with CTRL-z to suspend the process, and then bg to resume it in the background. Once running as a background process, you can disconnect and it will keep running.

If you need to reattach the process to a terminal later, you can use reptyr, which should be in your distributions repositories.

  • Under bg, will the process get killed when the ssh session close? – Will Oct 7 '15 at 13:28
  • 1
    No, it will keep running in the background. If you disconnect and reconnect you'll be able to see it in the process list. – seumasmac Oct 7 '15 at 16:07

disown should prevent the shell from sending it a HUP or such on exit of the shell.

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.