[Cialug] Looking for a simple parallelization command
Barry Von Ahsen
barry at vonahsen.com
Tue Nov 11 12:56:30 CST 2008
Eric Junker wrote:
> John Lengeling wrote:
>> Are there any simple utilities out there which when given a list of
>> commands will run them parallel?
>
> Bash supports subshells which should allow you to execute multiple
> subtasks simultaneously.
>
> http://tldp.org/LDP/abs/html/subshells.html
Andrew Howard posted this to cedarlug a while back (backgrounding and wait):
>Are there any good ways to get process level parallelism in a shell
>script?
>
>I have a shell script that calls about 8 independent programs, one
>after the other, before calling a 9th that processes the 8 programs'
>outputs.
>(One could consider it a bit of a "reduction".)
>
If it can be done, it can be done in bash:
#!/bin/bash
prog1 () { echo Program 1; }
prog2 () { echo Program 2; }
prog3 () { echo Program 3; }
prog4 () { echo Program 4; }
prog1 > /tmp/prog1out & pid1=$!
prog2 > /tmp/prog2out & pid2=$!
prog3 > /tmp/prog3out & pid3=$!
prog4 > /tmp/prog4out & pid4=$!
wait $pid1 $pid2 $pid3 $pid4
cat /tmp/prog[1-4]out
-barry
More information about the Cialug
mailing list