Executes scripts parallelly based on their success


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executes scripts parallelly based on their success
# 8  
Old 02-10-2014
Hi Cero ,
Thanks for reply ,
Can you plz help me the command you have suggested
Code:
wait
[ -f x.flagfile -a -f y.flagfile ] && Z.sh

this means this success condition would have to check with " if " loop ?

I have tried with below logic but failed if X and Y scripts are not finishing at same time

Code:
X.sh &
Y.sh &
wait (10)
s1_addr=`sed -n "1{p;q;}" $temp/x_success.tmp |cut -d ":" -f1`
s1_cont=`sed -n "1{p;q;}" $temp/y_success.tmp |cut -d ":" -f1`
if [ $s1_addr == "success" && $s1_cont == "success"  ];then
Z.sh

# 9  
Old 02-10-2014
Actually I like Don Craguns solution better than the one I suggested because you do not need flagfiles.
The wait command without an argument waits for all background jobs you submitted. When you give an argument it is interpreted as the process id to wait for.
I'll try to explain Don Craguns code:
Code:
# start X.sh in background
bash X.sh &
# store the process id of X.sh in the variable Xpid
Xpid=$!
# start Y.sh in foreground. If Y.sh finishes sucessfully wait for X.sh to finish.
# wait $Xpid returns the return code of the process that was waited for (X.sh)
# if this was sucessfull start Z.sh in foreground. 
bash Y.sh && wait $Xpid && bash Z.sh
# the syntax A && B && C says: start A, then if it returned success start B, then if B returned success start C

These 2 Users Gave Thanks to cero For This Post:
# 10  
Old 02-17-2014
Thanks Don ,
Mentioned logic is work well ..!!!
Thanks for your suggestion .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to optimize the loop to load parallelly

Hi, I'm trying to load the huge amount of records in the database. I did the successful load but it took more time to load as numbers are huge. Here what I have - 1. create a database table (t) with 2 columns- Not an issue 2. create a script to load huge amount of data - Here I would... (2 Replies)
Discussion started by: Mannu2525
2 Replies

2. Shell Programming and Scripting

To execute scripts parallelly

Hi I have set two set of scripts sets in a file which perform similar operations but with different script names for e.g.: 1st set of script1.txt: 1.sh 2.sh 3.sh 4.sh 2nd set of script2.txt: 1_1.sh 2_1.sh 3_3.sh 4_4.sh I want to execute these set of scripts parallelly in such... (16 Replies)
Discussion started by: rohit_shinez
16 Replies

3. Shell Programming and Scripting

Search patterns in multiple logs parallelly.

Hi All, I am starting a service which will redirect its out put into 2 logs say A and B. Now for succesful startup of the service i need to search pattern1 in log A and pattern2 in log B which are writen continuosly. Now my requirement is to find the patterns in the increasing logs A and B... (19 Replies)
Discussion started by: Girish19
19 Replies

4. Programming

Python Conditional Statements Based on Success of Last Command

In shell scripting, I can create a conditional statement based on the success or failure (exit status)of a command such as: pinger() { ping -c 2 $remote_host >/dev/null 2>&1 ping_stat=$? } pinger if ]; then echo "blahblahblah" exit 0 fi how is this done using Python using... (3 Replies)
Discussion started by: metallica1973
3 Replies

5. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

6. Shell Programming and Scripting

Running Multiple scripts based on file size.

Hi, I have created 3 shell scripts which has to run one by one first two shell scripts will create a .txt files...which are used by the third shell script.Now I want to create a master script and run all these in a single script. Please give a pseudo code on how to so the same. ... (4 Replies)
Discussion started by: gaur.deepti
4 Replies

7. UNIX for Dummies Questions & Answers

Scripts based on vi

since no one can give me mapping or scripts to make vi easier I'm thinking about writing some for it. But first I need some help (hopefully this one will be answered) 1) How do I execute scripts based on user action ex. user press ctrl+h I let him insert stuff and then making a search based... (6 Replies)
Discussion started by: Bonzay0
6 Replies

8. Shell Programming and Scripting

Time based Processing of the Scripts

Any one can tell me how can i execute the processes for every 10 min.Actually iam having 3 Processes for every 10 min i want to run these 3 Process,one process at every 10 min. If any of the process is busy i just want to execute the free one. first 10 min execute P1 next 10 min execute P2... (3 Replies)
Discussion started by: krk_555
3 Replies

9. Shell Programming and Scripting

Need a simple file based utilty for shell scripts

Hello, I'm wondering if you may know of a simple file based UNIX utility that can be used to store and retrieve values on a flat file, let's say i have a file called "kru", i'd like to be able to specify a request like: while(....) if ; then kru.fld2 = $rec_cnt kru.fld3 =... (4 Replies)
Discussion started by: bobk544
4 Replies

10. Shell Programming and Scripting

Running three scripts parallelly

Hi All, We have three shell script batch, which extract data from three different systems(oracle, db2, db2/400). By running each shell script batch, the data is extracted from respective systems. while the batch is running, job date, system_name, start_date and end_date will be inserted into... (1 Reply)
Discussion started by: anwarsait
1 Replies
Login or Register to Ask a Question