I've got a master script that reads 5 lines from a file and executes 5 distinct shell scripts at a time and waits for 5 to finish before starting the next batch:
cat file |
while read line1 && read line2 && read line3 && read line4 && read line5
sh script1.sh &
sh script2.sh &
sh script3.sh &
sh script4.sh &
sh script5.sh &
wait
Is there a way to ensure that there are always 5 scripts running at a time even if scripts {1,3} complete. ie if 1-5 are running concurrently and 1,2 finish. Start 6,7 immediately.