Hung script as a result of bg process
Hello Everybody,
I have been struggling with this issue for quite some time, and the resolution that I found isn't so pretty, it solved my problem, I wonder if somebody has a "prettier" idea.
scenario:
I have a script x on machine a that shh's to machine b, and invokes a script y.
I need in case of successful exit status of script y on machine b to return to my script x on machine a and do some more work on machine a.
so my script x waits for return status from script y.
now script y invokes 2 things, the first one runs as a bg process, the second is not a bg process.
the thing is that bg process didn't let me exit from the script, so i couldn't return to my script x. the script was hung although all the services were successful
this is the way that i found to solve it:
(nohup bgscript >/dev/null 2>&1 &) &
(nohup bgscript >/dev/null 2>&1 &) &
p.s.: here bgscript is the first thing that needs to be invoked
without "double backgrounding" the bg process, script y didn't exit
Anybody has a nicer way of doing it?
Waiting for your replies
Thank you all in advance
Last edited by Poki; 04-30-2009 at 11:16 PM.
|