Thursday, October 22, 2009

When you forget to start screen...

Screen and nohup are great tools which can be used, by someone with forethought, to keep their processes running after they disconnect from a server.

The problem with both nohup and screen is that you need to use them before starting a process. If you forgot or didn't realize the process was going to take ages then your all out of luck.

Recently on a man page hunt I discovered a workaround for this situation using disown. At the terminal with the long running process enter the following:

ctrl + z  (pause the current process and background it)
bg        (resume the last backgrounded process in the background)
disown    (disassociate the last process from the current terminal) 
exit      (to close the current terminal)

Now your disconnected, your process is still running and you can go home. If you don't want to go home and instead want to check that your process is still running, ssh back into your server and run ps aux and hunt it down in the process list.

2 comments:

Joey Smith said...

You should look into reptyr - it will put it in a screen session for you!

Troy Astle said...

Thanks! Looks great, I'll have to give it a try.

Post a Comment