2017-03-04 10 views

答えて

0
json='list.json' 
wget -o $json http://fileserver/getFileList 

jobsCount=0 
while IFS= read -r url ; do 

     #download the file 
     wget -q $url & 

     #contorling the amount of concurrent jobs 
      while true; do 
      #get current background job count 
      jobsCount=$(jobs -p | wc -l) 

      if [ $jobsCount -lt 6 ]; then 
       echo "jobsCount $jobsCount" 
       break 
      fi 
      echo "jobsCount $jobsCount (Sleep)" 
      sleep 1 
      done 

done < <(jq -r '.data[] | (.URL)' <$json) 
#wait for last batch of job to finish 
wait 
関連する問題