I’ve done something similar but not in Linux but a different UNIX OS (Tru64). It was to start multiple backups up to a predefined limit. The method I used was to run each instance as a child process in the background. Before I started an instance I checked how many were already running in the background with the ‘jobs’ command and if it was at the max, looped until one or more had finished. That code looks something like this:
Code:
typeset integer _ct
<start your for each loop>
_lp=”yes”
while [ “$_lp” = “yes” ]
do
_ct=`jobs | wc –l`
if [ $_ct –lt 4 ]
then _lp=”no”
else sleep 60
fi
done
<start the next instance>
<end of your for each loop> Remember to do another wait loop again after your for each loop to allow those child processes remaining time to finish.
There was discussion about backup processes in another thread that you might want to review.
http://www.linuxforums.org/forum/lin...t-command.html
Hope that helps.