[svlug] Running a command n times simutaneously

Peter Neal ptor at speakeasy.net
Tue Apr 25 11:05:52 PDT 2006


On Tuesday 25 April 2006 09:23 am, Rufoo wrote:
> For a performance measurement task I need to run a
> command n>1 times simultaneously. Is there any tool
> that can help me do this? 
> 
> Thanks.
> --r

Some bash script maybe...

pneal at nyarlathotep:~/temp> more ./test.sh
#!/bin/bash

echo "begin test..."
j=0
while [ "$j" -lt 10 ]; do
 (sleep 20) &
 j=`expr $j + 1`
done
n=`ps ax | grep "sleep 20" | wc -l`
echo "there are now $n sleepers sleeping:"
echo
ps ax | grep sleep
wait
echo "end test..."


pneal at nyarlathotep:~/temp> ./test.sh
begin test...
there are now 10 sleepers sleeping:

 9661 pts/2    S+     0:00 sleep 20
 9663 pts/2    S+     0:00 sleep 20
 9665 pts/2    S+     0:00 sleep 20
 9667 pts/2    S+     0:00 sleep 20
 9669 pts/2    S+     0:00 sleep 20
 9671 pts/2    S+     0:00 sleep 20
 9673 pts/2    S+     0:00 sleep 20
 9675 pts/2    S+     0:00 sleep 20
 9677 pts/2    S+     0:00 sleep 20
 9679 pts/2    S+     0:00 sleep 20
end test...




More information about the svlug mailing list