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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multiple child scripts running in backgroud, how to use grep on the parent?
# 1  
Old 08-01-2008
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
# 2  
Old 08-01-2008
Use the shell's wait command.
# 3  
Old 08-01-2008
is it possible to run the main script in background as well? while it waits for the child scripts to complete..
# 4  
Old 08-02-2008
Yes, absolutely. In fact I would suggest you take out the nohup for the child processes and run the main script with nohup instead.
# 5  
Old 08-02-2008
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
# 6  
Old 08-02-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing multiple child scripts - failing

Hi Folks - Happy Thursday! I have a need where I have Parent/Control script that calls multiple child scripts. The problem is, after the first child script is executed, it fails to move to the next script. I assume it's due to my script exit? For instance, in batch to return to the parent... (12 Replies)
Discussion started by: SIMMS7400
12 Replies

2. Shell Programming and Scripting

Moving files from parent path to multiple child path using bash in efficient way

Hi All, Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created. /Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt /Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Discussion started by: karthikgv417
6 Replies

3. Shell Programming and Scripting

How to exit from the parent script while the child is running?

hi, i want to call a child shell script from a parent shell script. the child will be running for 5 mins. normally when the child is running, parent will wait till the child completes. so in the above case parent will be paused for 5 mins. is there a way so that the parents does not wait for the... (3 Replies)
Discussion started by: Little
3 Replies

4. Shell Programming and Scripting

Multiple child running parallel

Hi , I am using sun Solaris machine. The machine description is given below SunOS ptxsa021 5.9 Generic_118558-24 sun4u sparc SUNW,Sun-Fire-15000 I am using korn shell.the scripts is below Parent code is given below..it is the part of code #!/bin/ksh # Script Name:... (3 Replies)
Discussion started by: ashutosh2378
3 Replies

5. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

6. Homework & Coursework Questions

Need help with deleting childīs parent and child subprocess

1. The problem statement, all variables and given/known data: I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process. 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies

7. Shell Programming and Scripting

Strange SIGINT propagation between Parent/Child sh scripts

Good day, I am trying to add signal handling capabilities to some of my scripts. Unfortunately, I am having some difficulty with the manner in which signals are propagated between parent/child processes. Consider the following example: I have the following "parent" script: #!/usr/bin/sh... (5 Replies)
Discussion started by: danie.ludick
5 Replies

8. Shell Programming and Scripting

How to export a variable from a child process running in background to the parent

Hi All, I have a script which calls a child script with a parameter to be run in the background . childscript.ksh $a & Can any one suggest me how do i export a variable from the child script to parent script? Note that the child script is in background If the child script is in... (3 Replies)
Discussion started by: aixjadoo
3 Replies

9. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

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: ... (1 Reply)
Discussion started by: albertashish
1 Replies

10. Shell Programming and Scripting

Error trapping in parent/child scripts

Greets all. I'm using Slackware 12.0 with the bash shell. Calling my scripts with /bin/sh... I'm building gnome-2.18.3 and I have all my build scripts ready and working but I'm calling them from a parent script which executes each child/build script in a certain order (for loop). I have "set... (6 Replies)
Discussion started by: madpenguin
6 Replies
Login or Register to Ask a Question