To execute scripts parallelly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To execute scripts parallelly
# 8  
Old 05-18-2014
Ok so something like this is can add right

Code:
  wait
if [[ -f $script1.completed && -f $script2.completed ]]
then 
proceed 

done < script1.txt 3<script2.txt

# 9  
Old 05-18-2014
Well. Proceed is the default, so it would be a loop break, rather than proceed, something like
Code:
[[ -f "$script1.completed" && -f "$script2.completed" ]] || break

# 10  
Old 05-18-2014
Ok fine how to add the name like $script1.completed becoz in my file i will have 1.sh so it should read as 1.completed rather than 1.sh.completed since the loop will hold $script1 assigned as 1.sh
# 11  
Old 05-18-2014
Either change the name of the completed flag or try something like parameter expansion, "${script1%.sh}.completed"

Last edited by Scrutinizer; 05-18-2014 at 07:18 AM..
# 12  
Old 05-18-2014
I can't change the flag its the standard flag maintained but variable extension will not be touched as the flag it will 1.completed or 1_1.completed. So need to check the file with $script1.completed by taking the basename of the $script1 variable

Not getting with the below code i have deleiberity not touching completed flag in 1_1 script but rest of the set is getting executed. Considering in my script files i am not having .sh extensions

Code:
hile read script1 && read script2 <&3
do
  "./$script1" &
  "./$script2" &
  wait
[[ -f "${script1%}.completed" && -f "${script2%}.completed" ]] || break
done < s1.txt 3<s2.txt


Last edited by rohit_shinez; 05-18-2014 at 07:23 AM..
# 13  
Old 05-18-2014
Yes that is what I mean, compare:
Code:
$ foo=bar.sh
$ echo "${foo%.sh}.completed"
bar.completed
$

# 14  
Old 05-18-2014
I tried something like this but the next set is running which shouldn't


Code:
while read script1 && read script2 <&3
do
  "./$script1" &
  "./$script2" &
  wait
if [[ ! -f "${script1%}.completed" ||  ! -f "${script2%}.completed" ]]
then
exit 1
fi
done < s1.txt 3<s2.txt
~

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Need ./ to execute scripts

Hi, I am really sorry for this question but still i am confused. I have shell script called sample.sh I can execute only with the combination of ./sample.sh Is ./ really necessary ? Is it something related with $HOME or $PATH variable. Why and How can i resolve this case ? ... (2 Replies)
Discussion started by: Nandy
2 Replies

2. Shell Programming and Scripting

Executes scripts parallelly based on their success

Hi Team , I have one Master.sh file which call X,Y,Z scripts , but here X may call again some sub scripts X_sub1.sh , X_sub2.sh Y calls Y_sub1.sh,Y_sub2.sh and similarly Z script also . Now requirement is Both X and Y should execute parallel bcz X and Y are independent... (9 Replies)
Discussion started by: chandini
9 Replies

3. Shell Programming and Scripting

Execute scripts in Parallel

Hi I want to execute few scripts in Parallel. There is a Master Script (MS.ksh) which will call internally all the scripts we need to run in Parallel. Say there are three set of scripts : ABC_1.ksh --> ABC_2.ksh --> ABC_3.ksh (execute ABC_2 when ABC_1 is successful ; Execute ABC_3 only when... (6 Replies)
Discussion started by: dashing201
6 Replies

4. Shell Programming and Scripting

Need to execute different scripts with shell script

Hi All, Am in need of some inputs to overcome the following problem, A tar file(/var/execute/scripts/ that contains different types of scripts(may be perl,shell, python etc...). I have written a shell script which is located @ /var/execute.sh to untar the file in some location say... (1 Reply)
Discussion started by: SMNK
1 Replies

5. Shell Programming and Scripting

need to have a cronjob which will execute certain scripts every hr

Hi My question needs two answers how to write scripts to update a table in oracle db based on the result of the number of record counts for example i need to execute the following script every hour awk '{sum++;}END{for(i in sum) {print i, sum}}' filename here everyhour the... (3 Replies)
Discussion started by: aemunathan
3 Replies

6. Shell Programming and Scripting

Execute scripts from remote using telnet

Hi having the below code (sleep 1 echo "username" sleep 2 echo "password" sleep 2 echo "cd /home/test1/path" sleep 10 echo "ls -l | grep filename" if exists echo "script1.sh filename" echo "mailx -s "Task Executed" user@domain.com" else echo "mailx -s "File not Exist"... (1 Reply)
Discussion started by: karthikn7974
1 Replies

7. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

8. 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

9. Shell Programming and Scripting

How to execute scripts at logout?

Hi, We can execute scripts at X login time in Linux by placing scripts in /etc/X11/xinit/xinitrc.d/ directory. Can you suggest a method to execute scripts at X logout time? rgds, pcsaji (1 Reply)
Discussion started by: pcsaji
1 Replies

10. UNIX for Dummies Questions & Answers

How can I execute TCL scripts in HP-UX

Hi All, Since I want to execute TCL scripts in HP-UX, I cannot find where to start. I try to execute the following scripts. It gets "tclsh: not found." errors. Where / how to execute tcl scripts? Thanks a lots. #!/bin/sh # the next line restarts using wish \ exec tclsh "$0" "$@" (3 Replies)
Discussion started by: wilsonchan1000
3 Replies
Login or Register to Ask a Question