Re: how to refrain only use certain number of processors
On Mon, Jan 30, 2012 at 06:06:06PM +0800, lina wrote:
> I have a script like
>
> #!/bin/bash
> for i in {0..108}
> do
>
> some job will run for mins &
> done
>
> Here I used & for some kinda of parallel.
> but there is a problem,
> I wished at most it only run 8 jobs simultantly, no more than 8, once
> finished, a new job can continue,
> Some suggestions?
how about instead of one script, running 8 scripts from cron, each has
its own lock file:
------------------------------------
#!/bin/sh
#script no.1
LOCKFILE="$HOME/lockfiles/lock_1"
if [ -f $LOCKFILE ]; then
exit 1
else
echo "green light .."
fi
date -u > $LOCKFILE
do something
rm $LOCKFILE
------------------------------------
--
Chen Wei
Reply to: