Reputation: 215
I am trying to run a command across some lines in a text file. I am using for loop for this as below.
for LINE in `cat $LogDir/details.lst`
do
#Queue state dump
#The following amqldmpa command dumps the queue state every 10 seconds for one minute.
amqldmpa -m $QMGR -c A -u 1 -q $LINE -d 3 -n 6 -s 10 -f $LogDir/$LINE.txt
done
Now there are close to 20 lines in the details.lst file. How can i run this command against all these lines at the same time in parallel? Also how can i get out of the for loop only after all the lines have been successfully executed in the command?
Please help.
Upvotes: 0
Views: 86
Reputation: 247052
wait
builtinwhile IFS= read -r line; do
amqldmpa --options... &
done < "$LogDir/details.lst"
wait
echo "all jobs done"
You do lose the exit statuses of all the backgrounded jobs that way though.
Upvotes: 2