#!/bin/bash # Specify maximum number of jobs in queue Nmax=20 # Specify total number of jobs to run RUNSmax=100 i=1 while [ 1 ] do NUM=`showq | grep username_on_vampire | wc -l | sed "s/ //g"` if [ $NUM -lt $Nmax ] then if [ $i -gt $RUNSmax ] then exit 0 fi cat Input.txt | sed "s/SCRIPTOUT/$i/g" > InputFile_$i.txt # This iterates a counter within the Input batch file and renames it as InputFile#. cat PBS.txt | sed "s/SCRIPTOUT/$i/g" > Submit.pbs # This iterates a counter within the PBS file and renames it as Submit. qsub submit.pbs # This actually submits the job to the queue. i=`expr $i + 1` else sleep 600 fi done