Parallel for in a Script Shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parallel for in a Script Shell
# 1  
Old 05-01-2015
Parallel for in a Script Shell

Hello,
This is my Script which configure a list of nodes. ( 40 nodes, and the configuration 10 minutes)
Code:
#! /bin/sh
if [ $# -ne 1 ]
then
 echo "USE: ./start.sh nodes
 else
nb_lignes=`wc -l $1 | cut -d " " -f1`
  echo "$nb_lignes machines"
for i in $(seq $nb_lignes) 
//instructions
done
fi

My question:: Please how can i parallelize the loop for ?


Thanks a lot.
Best Regards.
# 2  
Old 05-01-2015
Hi

You could try something like:
Code:
for n in 15 28 37
do   ./start.sh $n &
done

If that is not what you want, please be more elaborate or use the search function of the forum, there are quite a few threads on this topic.

hth
# 3  
Old 05-02-2015
Run the entire //instructions in a subshell in the background like ( //instructions ) &.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parallel processing in AIX (bash shell scripting)

Hi all, I am struggling to build a utility which can do the parallel processing. I achieved same in Linux using xargs -P but same is not working on AIX. I am building file copy utility where I will have all required info in a file (like souce file info and target location details), now i need... (2 Replies)
Discussion started by: ankur singh
2 Replies

2. Shell Programming and Scripting

Parallel Runs in UNIX/Linix Shell Scripting

HI, I have a file(suppose 1 million Records), i wanted to divide file into chunks(100 small files), these all files should run parllell(e.x like threads) to utilize the process for fast processing. Can you please provide a solution for the above issue. Ex: Split -b 2m file.txt file,... (1 Reply)
Discussion started by: prawinmca
1 Replies

3. Shell Programming and Scripting

Running 3 shell script parallel in another shell script

Hi, I'm trying to do teh below thing. I have a single script which uses 3 different parameters to do 3 different work like belwo. test1.sh par1 -- it shuts down an instance test1.sh par2 -- it shuts down an instance test1.sh par3 -- it shuts down an instance Now I created a script... (7 Replies)
Discussion started by: bhaski2012
7 Replies

4. Shell Programming and Scripting

Parallel processing of SQL through Shell

Hi Friends, I am trying to write a shell which will invoke 3 CTAS (ORACLE create table XXX as select * from YYYY). The approximate time for one CTAS is around 25 mins. So i want to run the CTAS script parallely. My pseudocode is as below. Main script nohup sh CTAS1.sh &... (3 Replies)
Discussion started by: Showdown
3 Replies

5. Shell Programming and Scripting

Executing Multiple Queries in parallel in Shell

I have n number of SQL queries needs to executed in Shell. Result of this query need to assign in a variable. Once all the queries are executed script needs to exit. Sample Query: SQL 1: Select Count(*) from TABLE GROUP BY COL1,COL2 SQL 2: Select Count(*) from TABLE GROUP BY COL1,COL2 ... (2 Replies)
Discussion started by: Niranjancse
2 Replies

6. Shell Programming and Scripting

Parallel SQL sessions in shell script

i have 3 sqls , sql 1 and sql 2 shuld run in parallel , but sql 3 should run after completion f sql1 nd sql2, my code is as below, please suggest the changes sqlplus username1/password1@DB1 @sql >> log1 & sqlplus username2/password2@DB2 @sql2 >> log1 & how can i execute the... (7 Replies)
Discussion started by: only4satish
7 Replies

7. Shell Programming and Scripting

Help with executing parallel sessions for same shell script with different but fixed parameters

Hi Experts, There is a shell script that accepts positional parameter between 1-25 to execute case statement of script depending upon the parameter passed. Now I need to run all the 25 sessions parallely. In each option of case statement it is connecting with sqlplus and executing a select... (11 Replies)
Discussion started by: Opamps123
11 Replies

8. Shell Programming and Scripting

Running shell script in parallel

Hi, I am a shell script which takes input parameters and performs various functions. My concern is, if we call the same shell script with different parameter values from different sessions, will the results be inconsistent? Are there any precautions I need to take inorder to avoid conflicts... (1 Reply)
Discussion started by: jamjam10k
1 Replies
Login or Register to Ask a Question