I am trying to run a c executable through bash. The executable will take a different argument in each iteration, and I want to do it in parallel since I have 12 cores available.
I tried
w=1;
for i in {1..100}
do
l=$(($i-1));
for j in {12*l..12*i}
do
./run $w/100 > "$w"_out &
done
expr=$w % 12;
if ["$expr" -eq "0"]
then wait;
fi;
done
run is the c executable. I want to run it with increasing argument w in each step, and I want to wait until all processes are done if 12 of the cores are in use. SO basically, I will run 12 executables at the same time, then wait until they are completed, and then move to the next 12.
Hope I made my point clear.
Cheers.
{12*l..12*i}supposed to do arithmetic? A multiplication? You are not using thatjin the loop. Is that intended? Is the$W % 12supposed to perform math as well? Are you interested in error handling of all the different calls as well?wis never changed? It is just set to1in the beginning, and that's it.expras a variable name is likely to cause grief at some point... Some code indenting/formatting might make things a bit easier to understand. Add aset -xbefore your loop(s) to see exactly what is being run...