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?
2 Answers
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? Commented Oct 7, 2015 at 13:28 -
1No, it will keep running in the background. If you disconnect and reconnect you'll be able to see it in the process list. Commented Oct 7, 2015 at 16:07
disown
should prevent the shell from sending it a HUP
or such on exit of the shell.