Question : Shell script to queue commands

I need a simple script that will process 100 commands.
It will initially start the first 8 commands.
As each command finishes it will start the next command always keeping 8 running at a time until all of them have been completed.

the commands to be executed looks like this
it changes to a directory, runs and executable passing it the ctl file name and logfile name

cd simrun01
./simrun < FCON> simrun01.out
cd ../simrun02
./simrun < FCON> simrun02.out
cd ../simrun03
./simrun < FCON> simrun03.out
cd ../simrun04
./simrun < FCON> simrun04.out
cd ../simrun05
./simrun < FCON> simrun05.out

Any ideas would be appreciated.

Russ

Answer : Shell script to queue commands

I think this is a simpler approach
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
#!/bin/bash

cd /some/path

for dir in simrun*
do

  while true
  do
    if [ $(jobs | wc -l) -gt 8 ]
    then
       sleep 1
    else
       $dir/simrun <FCON> $dir/$dir.out &
       break 2
    fi
  done

done
~
Random Solutions  
 
programming4us programming4us