8

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?

Thrawn
  • 315
  • 3
  • 9

4 Answers4

11

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.

Douglas Leeder
  • 1,485
  • 9
  • 13
5

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.

alanc
  • 1,074
  • 6
  • 12
coneslayer
  • 8,652
  • 1
  • 28
  • 23
  • 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
2

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

Jonathan Heady
  • 3,671
  • 22
  • 16
  • 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
  • 1
    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. – Jonathan Heady Mar 26 '10 at 23:17
2

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.

geek
  • 9,746
  • 3
  • 21
  • 16