Shell Bash multiprocessing CPU issue

I execute the code below with BASH. After a while CPU is getting 60%-70% and then full. What can cause this and how can I fix it? I am using FreeBSD 9.
Code:
#!/bin/bashset-bm
startjob(){if[ $count -lt $total_jobs ];then
echo $started ve $count
curl -o /depo/$count".txt"-s "http://api.domain.com/$count"&
count=$(($count+1))fi}
max_parallel=200
total_jobs=100000

trap 'startjob' SIGCHLD
count=0
started=0while[ $started -lt $max_parallel ];do
startjob ||break;
sleep 0.01;
started=$(($started+1))# echo $starteddone
wait
 
Back
Top