parallel iterations in for loop in shell -
i trying run command across lines in text file. using loop below.
for line in `cat $logdir/details.lst` #queue state dump #the following amqldmpa command dumps queue state every 10 seconds 1 minute. amqldmpa -m $qmgr -c -u 1 -q $line -d 3 -n 6 -s 10 -f $logdir/$line.txt done
now there close 20 lines in details.lst file. how can run command against these lines @ same time in parallel? how can out of loop after lines have been executed in command?
please help.
- that's wrong way iterate on lines of file. use while loop.
- put each amqldmpa in background
- assuming shell bash, use
wait
builtin
while ifs= read -r line; amqldmpa --options... & done < "$logdir/details.lst" wait echo "all jobs done"
you lose exit statuses of backgrounded jobs way though.
Comments
Post a Comment