Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How do I detach a process from Terminal, entirely?

I've a program running in a Unix console on a remote Unix computer. I (stupidly) didn't run it using nohup &, and now I need to close the local console.

Is there any way to have it keep running remotely after closing the local console?

share|improve this question

marked as duplicate by slhck Aug 5 '12 at 18:43

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.

4 Answers 4

up vote 2 down vote accepted

If you can afford to stop the program and restart it before logging out, then stop it and restart it through screen, which is a must for anybody using remote connections to unix hosts.

share|improve this answer
I think the main problem here is precisely that he would like to not stop the program. –  Gnoupi Mar 26 '10 at 15:34
Yeah, I would like the program not to be stopped :-) –  Thrawn Mar 26 '10 at 18:32
I would highly suggest screen for future use of such a situation (I pretty much always have a screen session running on any system i have a sehll o). –  Matrix Mole Mar 26 '10 at 23:16
Several years later, I realized I was a fool not to be using screen :-) –  Thrawn Aug 27 '12 at 12:48

If your shell is bash, they you can use disown. Ctrl-Z to suspend the process, then disown -h to make it not receive SIGHUP.

share|improve this answer
Brilliant solution. It worked :-) –  Thrawn Mar 29 '10 at 9:22
Just curious: as the process is suspended, shouldn't this eventually be followed with bg or something like that? Or does disown -h resume it as well? –  Arjan Apr 25 '10 at 15:13

On Solaris 9, you can use nohup -p <pid> to nohup a running process. Here's an interesting explanation of the implementation. I don't know if this has been implemented on any other Unices.

share|improve this answer
nohup: invalid option -- p Doesn't work on gentoo, ubuntu or fedora (the unixes I tried this on), but thanks nevertheless :-) Good to know Solaris has it. –  Thrawn Mar 26 '10 at 18:37

Ctrl-Z to suspend the process, then bg to cause the program to go into the background and keep running until it completes.

share|improve this answer
Problem is that if I close the console, also the background processes will stop. I need something that detaches the process from the console, like nohup does, but after the process has started :-) –  Thrawn Mar 26 '10 at 12:58
And I don't think 'nohup bg &' will work either :-( –  Thrawn Mar 26 '10 at 13:19
I tried it on one of my systems and it kept running fine when I logged out (just used du / >> temp as the test progrm) but I understand being hesitant if you don't want to lose the program or it's results. –  Matrix Mole Mar 26 '10 at 23:17

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