Implement parallel processing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Implement parallel processing
# 8  
Old 07-19-2013
Why spin up another terminal? You can background the processes with this:-
Code:
counter=1
until [ $counter -ge 10 ]
do
   some_script ${counter} &
   ((i=$i+1))
done
wait             # Script will not continue until they all finish

This, of course, assumes that some_script can recognise the counter as meaning something. If you just have five distinct scripts to run, you could just:-
Code:
first_script  &
second_script &
third_script  &
fourth_script &
fifth_script  &

wait             # Script will not continue until they all finish


Do either of these options help?


Robin
Liverpool/Blackburn
UK
# 9  
Old 07-19-2013
Hi rbatte1...

Quote:
Why spin up another terminal?
Why indeed, except that with these extra terminals running one can keep a watchful eye on each _child_ as it _runs_. Also you can see immediately when the script has done its all, as it will autoclose, _no_longer_to_be_seen_... ;o)

No other reason than that.

You can also give each terminal its own number that shows in its header bar so you know how each task is progressing...

All good fun... ;o)
# 10  
Old 07-19-2013
Quote:
Originally Posted by kumarjt
Does any of the wordings in my original post give you the feeling that I am seeking help for a HOMEWORK ASSIGNMENT?
Your question is oddly specific for someone who doesn't know how to program in this language, so, yes.

You can run a process in the background in shell with
Code:
programname &

# 11  
Old 07-19-2013
Quote:
Originally Posted by wisecracker
Why indeed, except that with these extra terminals running one can keep a watchful eye on each _child_ as it _runs_. Also you can see immediately when the script has done its all, as it will autoclose, _no_longer_to_be_seen_... ;o)
Very good point!

This is not suitable for all tasks however, and not everyone has xterm, so it's important to point out that this is optional.
# 12  
Old 07-19-2013
This might be a batch process request though...... I'm still unclear what's really wanted.
# 13  
Old 07-20-2013
@ wisecraker : I am using the method specified by millan ( for loop , and within each loop execute the command as background proces ) , and it works fine , but after all the iterations of the for loop is complete , the control does not come back to the shell prompt so that any subsequent conmmand could be executed . Please tell me how to bring back the shell prompt again at the end of the for loop.

Thanks
# 14  
Old 07-20-2013
Here is an example...
The launch code:-
Code:
#!/bin/bash --posix
var=""
for n in $( seq 1 2 )
do
	xterm -e ~/childmultitask.sh &
done
echo "Done!"
echo "You are still in your original calling script!!!"
echo "Your background srcipts are running now so......"
read -p "Press <CR> to go back to the terminal:- " -e var
exit

This is the child process:-
Code:
#!/bin/bash --posix
x=0
while true
do
	echo -n "$x "
	x=$[ ( x + 1 ) ]
	sleep 1
done

Attached is a snapshot of what was done.
Implement parallel processing-multitaskjpg
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parallel processing

I have 10,000 + files, each of which I need to zip using bzip2. Is ti possible to use bash to create 8 parallel streams sending a new file to be processed from the list when one of the others has finished? (1 Reply)
Discussion started by: garethsays
1 Replies

2. Shell Programming and Scripting

Parallel processing - continued

Hi, I am taking up the cue from where I was left in my earlier post ( link given below ) https://www.unix.com/shell-programming-scripting/231107-implement-parallel-processing.html I actually wanted to know the significance of using the Unix "wait" , which returns the control from background to... (3 Replies)
Discussion started by: kumarjt
3 Replies

3. Programming

Parallel processing pthread

Need urgent help on thread: the goal here is the separtemask will take each image and separate different contours and for each contour in the image it will call handleobject thread. So every for loop will call the handeobject thread. However, object index variable needs to be passed in each... (0 Replies)
Discussion started by: temursalin
0 Replies

4. Shell Programming and Scripting

Parallel processing in bash?

Hi Say I am interested in processing a big data set over shell, and each process individually takes a long time, but many such processes can be pipe-lined, is there a way to do this automatically or efficiently in shell? For example consider pinging a list addresses upto 5 times each. Of... (5 Replies)
Discussion started by: jamie_123
5 Replies

5. Shell Programming and Scripting

PARALLEL PROCESSING IN PERL

HI All, I have scenerio where I need to call sub modules through for loop for (i=0; i<30 ;i++) { .. .. .. subroutine 1; subroutine 2; } I want this to be run in parallel process1 { ... ... subroutine 1; subroutine 2; (0 Replies)
Discussion started by: gvk25
0 Replies

6. Shell Programming and Scripting

How to make parallel processing rather than serial processing ??

Hello everybody, I have a little problem with one of my program. I made a plugin for collectd (a stats collector for my servers) but I have a problem to make it run in parallel. My program gathers stats from logs, so it needs to run in background waiting for any new lines added in the log... (0 Replies)
Discussion started by: Samb95
0 Replies

7. Shell Programming and Scripting

parallel processing

hi i am preparing a set of batches for a set of files sequentially There is a folder /xyz where all the files reside now all the files starting with 01 - will be appended for one below other to form a batch batch01 then all the files starting with 02 - will be appended for one below other to... (7 Replies)
Discussion started by: mad_man12
7 Replies

8. Shell Programming and Scripting

Need Help With Parallel Processing

Hi I am looking for some kind of feature in unix that will help me write a script that can invoke multiple processes in parallel. And make sure that the multiple parallel processes complete successfully before I proceed to the next step. Someone suggested something called timespid or... (6 Replies)
Discussion started by: imnewtothis23
6 Replies

9. Shell Programming and Scripting

parallel processing

Hi I want to run two shell script files parallely. These two scripts are interacting with the database. can any body help on this Pls Regards Audippa naidu.M (3 Replies)
Discussion started by: audippa
3 Replies

10. UNIX for Dummies Questions & Answers

How to do parallel processing??

Hi All, I am working on solaris 8 sparc machine with 2 cpu. I am trying to run my application which generates files. I run multiple instance of the application, but the results don't seem to show as if it were runing parallely. When i run the application once it takes 12 secs to generate a... (1 Reply)
Discussion started by: zing
1 Replies
Login or Register to Ask a Question