Showing posts with label unix nohup background running. Show all posts
Showing posts with label unix nohup background running. Show all posts

Tuesday, April 3, 2012

nohup and background an already running process

So I have found myself in this situation more than once. I have a long running process running in a foreground, and i need to disconnect but dont want to loose the work already done by the process. The process is cpu intensive and thus is not responding to usual control+z. Here are steps you can take to force it into background and nohup it, making it possible to safely close the terminal window

open a new terminal window, find the process id of the long running process and do this

; suspend the process

kill -20

; or you can also use this

kill -stop

this should cause the process to be suspended in the original process. now you can background it. backgrounding it alone will not cause it continue running if the window is closed. you will need to disown it.

bg disown -h

the process is still suspended, so now resume it

; resume the process

kill -18

; or you can also use this

kill -cont