The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Monday, December 15, 2008

Executing a Process in isolation

I came across a scenario where I executed a child process from the parent process in linux. And The requirement was to kill the parent process and continue to run the child process. But in the default way of doing it will not help. As soon as the parent is killed all the child processes will be killed.

So what's the solution? 

Well nohup comes to the rescue. What you can do is something like nohup &
This is create the independent process and run it in background. So, even if parent proecss is killed it will continue to run. Just a sample code for this is:

mkdir vik
nohup ./test1.sh &

rm -rf abc         #say some huge directory

In the above example if u run test.sh then say dir abc in test1.sh is very huge and taking time to delete. In that case if you kill the parent script test.sh  then test1.sh will still continue to run.

No comments: