Hi all,
I have one requirement,I have two shell programs one is parent and the other one is child . from parent script i need to execute/trigger/call child script as background job. my requirement is after calling child script i want the child process information i.e PID of child weather it is still running or not?
I am written the following code in parent shell which returns 2 everytime i.e the output is "child not running".
If you are doing the test immediately after starting it and doing the test one only then you might as well assume that it *always* starts and is still running due to the independent nature of processes.
Are you going to repeatedly check the status of the child process, if so grab the $! value into a variable and check against that.
Hi,
Thanx for reply, I am not testing the child status repeatedly.testing only once after calling that as you said it should run.the child script contain some logic that runs for a while. depending upon that status i need to do further processing. to go ahead the child status should return it is running. if not i am unable to go ahead.
i tried with that what you suggested to assign that into a variable. in that case also same result i am getting.
Then it would be much more easier to identify the step from where other process can continue processing.
But again the granularity between sleeping and checking for any log messages is purely experimental and you have to give a random number for that.
parent process - starts the child process
child process logs the info in a file
controller process checks whether necessary message has been logged into file or not
if not then continue sleeping
if yes continue with the next steps
The following is a special christmas present for porter:
(c) use a semaphore or a semaphore-like file
(d) use the coprocess-facility
(e) with the necessary glue-logic you can even use sleep, like matrixmadhan suggested, but i have to agree it would be unnecessary effort given the number of other options.