Simutaneous scripts within a background task


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simutaneous scripts within a background task
# 1  
Old 10-23-2009
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 executed. My thinking is that because there's a "wait" command I intended for the 2 simultaneous scripts may actually be waiting for the main script to finish (which it never will).

Code:
        case $ApiId in
             15) nohup $ExecRep nyapimod15 -f import -u -s "rec1" >> $Null
                 nohup $ExecRep nyapimod15n -f scan -u -a -ia -v sel_scan >> $Null&
                 nohup $ExecRep nyapimod15a -f scan -u -a -ia -v sel_scan >> $Null&
                 wait
                 nohup $ExecRep nyapimod15 -f export -u -a -ia -v sel_scan >> $Null
             ;;
         esac

Can anyone tell me how I can catch when the 2 processes will finish using
wait? I'm using ksh. (red hat linux)

Thanks!

---------- Post updated at 04:48 PM ---------- Previous update was at 04:18 PM ----------

Found it ... I found that I needed to designate the pid for wait.

process1&
process2&
wait $!
process3

Thanks
G
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. Shell Programming and Scripting

[BASH] Script to manage background scripts (running, finished, exit code)

Heyas, Since this question (similar) occur every now and then, and given the fact i was thinking about it just recently (1-2 weeks) anyway, i started to write something :p The last point for motivation was... (17 Replies)
Discussion started by: sea
17 Replies

6. Shell Programming and Scripting

Redirecting stdout on background task

Hello, I have a script (videostream.sh) which invokes the GStreamer command-line tool gst-launch with all the correct command line parameters. When I invoke this program, I add the '&' character at the end to make it a background task, so that my script can complete and exit, i.e. gst-launch... (1 Reply)
Discussion started by: salukibob
1 Replies

7. Shell Programming and Scripting

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.. 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... (2 Replies)
Discussion started by: michaelrozar17
2 Replies

8. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

9. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 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