multiple child scripts running in backgroud, how to use grep on the parent?

Hi

I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running.

My Code:

nohup a.sh > /dev/null 2>&1

Code in a.sh:

nohup b.sh > /opt/portal/6.5/apps/b.txt &
nohup c.sh > /opt/portal/6.5/apps/c.txt &
nohup d.sh > /opt/portal/6.5/apps/d.txt &
nohup e.sh > /opt/portal/6.5/apps/e.txt &
nohup f.sh > /opt/portal/6.5/apps/f.txt &
nohup g.sh > /opt/portal/6.5/apps/g.txt &

i try to grep:
ps -ef|grep a.sh|grep -v grep

I must be able to do this successfully...

Kindly help..

Regards,
Albert

Use the shell's wait command.

is it possible to run the main script in background as well? while it waits for the child scripts to complete..

Yes, absolutely. In fact I would suggest you take out the nohup for the child processes and run the main script with nohup instead.

you may want to use while statement..
value=`ps -ef | egrep '(a|b|c|d|e|f).sh'
while [ ! -z "${value}" ]
do
echo child scripts are still running
done

HTH

try this, at the end of the parent script

value=`ps -ef | egrep '(a|b|c|d|e|f).sh'`
while [ ! -z "${value}" ]
do
echo child scripts are still running
done