On Mon, Jan 30, 2012 at 10:08 PM, Chen Wei <weichen...@gmx.com> wrote: > 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
This is a very nice options. I can use for i in {1..20} do something in script one, and i in {21..40} do something in script 2 and run those separately without &. Thanks, > ------------------------------------ > > -- > Chen Wei > > > -- > To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org > with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org > Archive: http://lists.debian.org/20120130140831.GB2756@Tungsten.DarkStar > -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/cag9cjmmvprrwh9vxs+lscws19ywdtfg8bgxcztzmfwhr6yz...@mail.gmail.com