Issue
Currently I'm stuck at running time consuming simulations efficiently. The intention is to run 4 simulations in parallel, because it's a single thread application and a quad core system. I have to variations of shell script:
./sim -r 1 &
./sim -r 2 &
./sim -r 3 &
./sim -r 4 &
wait
./sim -r 5 &
./sim -r 6 &
./sim -r 7 &
./sim -r 8 &
wait
... (another 112 jobs)
with this code there is a wait again and again. I also tried to split the tasks into four scripts and run each, result is that one script is finished while the other has about 30% of remaining jobs. I can't predict how long a simulation will take.
Any suggestion to have 4 simulations running at any time?
Solution
Install the moreutils
package in Ubuntu, then use the parallel
utility:
parallel -j 4 ./sim -r -- 1 2 3 4 5 6 7 8 ...
Answered By - pobrelkey Answer Checked By - Clifford M. (WPSolving Volunteer)