background scripts run-help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting background scripts run-help
# 1  
Old 08-17-2010
background scripts run-help

Looking for a logic where say i have a script called parent_script which is used to call other 4 to 5 child scripts in background as..
Code:
cat parent_script # containing 65 lines 
1
2
..
35 while read child_script
36 do
37 ./child_script_name&
38 done< ${SCRIPT_LISTS}
39
40 # Need to have some logic here such that the parent_script waits until all the child scripts completed execution
41
..# some other codes here
65

As you would know once the values in variable SCRIPT_LISTS rans out the parent script comes out of the while-loop and start processing the subsequent lines. I need to keep a logic such that parent_script waits until all the jobs running in the background completes execution and only then have to process the remaining lines from # 39-65.
Had an idea of sleep command but im not sure whether we could use sleep to wait..until.. some process completes because to this command we need to pass arg in seconds or minutes rather than asking it to wait..until.
Pls throw some of ur ideas and let me know if i need to be more clearer in my requirement.
# 2  
Old 08-17-2010
If you are using ksh, then the wait command without any options will wait until all asynch jobs have completed.

From the ksh manual page:
wait [ job . . . ]
Wait for the specified job and report its termination status. If job is not given, then all currently active child processes are waited for. The exit status from this command is that of the last process waited for if job is specified; otherwise it is zero. See Jobs for a description of the format of job.


The whole page is at:
Kshell Man Page

Bash's wait command operates in a similar fashion, however the return status from is very different than in Kshell, so if you are using bash, make sure you understand what it returns.
# 3  
Old 08-18-2010
Thank you for the suggestion. i will check on it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run scripts in background one by one

Hello all, Can someone help with one script? I have as example 3 scripts 1.sh sleep 60 & sleep 60 & sleep 10 & sleep 80 & sleep 60 & 2.sh sleep 40 & sleep 5 & sleep 10 & sleep 70 & sleep 60 & 3.sh (2 Replies)
Discussion started by: vikus
2 Replies

2. Shell Programming and Scripting

How to run scripts sequentially in background?

Hi , I have prepared the following shell script to run the hqls in background. These scripts are running Parallel but I want to run the hqls sequentially in background. cat >cc_script.ksh nohup hive -hiveconf rrdt=2016-06-12 -f /home/files/cust1.hql > home/log/cust1.log 2>&1 & nohup hive... (6 Replies)
Discussion started by: ROCK_PLSQL
6 Replies

3. Shell Programming and Scripting

Problems running scripts in the background

Hi Could someone offer some help on this problem I've got with running a background process. As part of a script that does a stop/start/status for a piece of software called SAS, the following extract is from part of the start step. My issue is that when the script is run, the control... (0 Replies)
Discussion started by: GavP
0 Replies

4. Shell Programming and Scripting

Running scripts in background

Hi, below is my master script wihch inturn runs 2 scripts in background #master_script.sh ./subscript1.sh & ./subscript2.sh & executed the master_script.sh from unix command prompt $ ./master_script.sh it is executing the subscripts and they are completing fine, however master_script.sh is... (2 Replies)
Discussion started by: JSKOBS
2 Replies

5. UNIX for Dummies Questions & Answers

Scripts can be run manually but couldn't run with cronjobs

I am from MQ/MB technology. My requirement is to display the queue manger and broker status on daily basis. If I manually run the script, it works fine and displays output. But when I have scheduled the same using cronjobs it shows only the queue manger status and not the broker status. Can... (3 Replies)
Discussion started by: Anusha M
3 Replies

6. Shell Programming and Scripting

Run wineconsole in background

Hello everybody, I'm making a script for running a .bat process on wineconsole, but I want that wineconsole doesn't show up when I call it from the script. The script is named "reset" and it looks like this: When I execute it, it will show up the wineconsole window on top, and that is... (3 Replies)
Discussion started by: taurokpo
3 Replies

7. Shell Programming and Scripting

Simutaneous scripts within a background task

Hi, I have a script that polls a directory using inotifywait. This script is always running in the background. Within that script, I have 2 commands that need to run simultaneously. When those scripts are finished, I have to fire off a 3rd. The problem is, the 3rd script is never being... (0 Replies)
Discussion started by: gseyforth
0 Replies

8. UNIX for Dummies Questions & Answers

can we run ssh2 in background

Hi, I was trying to run ssh2 command in background... but i got follwoing error message saying that process has been stopped.. + Stopped(SIGTTOU) Anyone have any idea about this??? Appreciated your help.. (3 Replies)
Discussion started by: pvamsikr
3 Replies

9. Shell Programming and Scripting

run a shell in the background

How can I run a shell in the background? cat test.sh #!/bin/sh sleep 600 Thank u very much indeed! (2 Replies)
Discussion started by: GCTEII
2 Replies

10. Shell Programming and Scripting

exit status of Invoking two or more scripts in background

I have a sript which is going to trigger other 3 scripts in background simultaneously for eg: Main Script:(main.sh) ----------- sh a.sh & sh b.sh & sh c.sh & How to catch the exit status and store it in a variable for all those three scripts in main script. Is there any other way of... (4 Replies)
Discussion started by: Omkumar
4 Replies
Login or Register to Ask a Question