After every third item, sleep [source]
counter=0
limit=3
foo="thing1 thing2 thing34 thing4 thing5 thing6 thing7 thing8 thing9 thing9"
for thing in $foo; do
( # start a subshell
# increment the counter, sleep & reset it if its over the limit
(( counter++ ))
(( $counter > $limit )) && sleep 3 && counter=0
echo "$thing"
# do a lot more things
) & # send process to background
done
This is useful if you want to run many simultaneous processes by pushing each loop iteration into the background, but want to pause every n
iterations so as not to flood the system too badly with processes.
Also you can use sleep $[ ( $RANDOM % 20 ) + 1 ]s
for a random sleep timer (up to 20s).