I have a text file which contain all the parameters need for scheduled jobs, then this "control" script would be called everynight at certain time
while read line
do
$myScript.sh $line &
pid[i]=$!
i=\`expr $i \+ 1\`
done < $list
then I need to wait until all these jobs to be completed before proceeding, so I do
i=0
while [[ $i -lt $\{\#pid[*]\} ]]
do
wait $\{pid[$i]\}
i=\`expr $i \+ 1\`
done
however, I notice that it would actually wait for the first job (pid at 0) to be done before continue to wait on job 2, how can I make it such that the wait occurs concurrently? thanks!!!