I am trying to bash script where it executes following java jar command in batch mode on the basis of size of list.
i have a list of string with 54 states of USA.
list = [USA+CA,USA+TX,USA+TN...]
i need to execute following command in parallel with 4 instances having 4 values as input from list.
java -jar test-execute.jar --localities=USA+TX,USA+CA,USA+TN,USA+AB
wait till execution is complete for any instance, then start new instance of jar with next 4 states.
array=( USA+TX,USA+CA,USA+TN,USA+AB )
for i in "${array[@]}"
do
java -jar test-execute.jar --localities= ???
done
I am not able to understand how can i dynamically provide inputs from array into jar execution.
so,
i have list of size 54,
i need to run 4 java instances in parallel with each instance having 4 unique state as input from list of 54. , once these instances complete, then start next 4 instances with next unique 4 states per instance.
update:
i have list of 54 states , 16 core machine. each java jar instance will use 4 cores, so i can run 4 java instances at a time to to use 16 core machine .
16 core machine
java instance-1 4 states
java instance-2 4 states
java instance-3 4 states
java instance-4 4 states
wait till any of these instances complete, once completed, start new instance with next 4 states until all 54 states has been executed.
please help.