[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to refrain only use certain number of processors



On Mon, Jan 30, 2012 at 6:06 PM, lina <lina.lastname@gmail.com> wrote:
> Hi,
>
> ( sorry if it a bit off-topic)
>
> 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?

#!/bin/bash

for i in {0..19}
do
sleep 60 &

while ($((ps au | grep sleep | wc -l)) > 9)
do
sleep 2
done

done

sorry the subject of the email should be "refrain using too many
processors at the same time."

above one not working, complained:

.sh: line 8: ps au | grep sleep | wc -l: syntax error in expression
(error token is "au | grep sleep | wc -l")


>
> Thanks,


Reply to: