Directly pass parameters to pbs script
The qsub
utility can read the script from the standard input, so by using a here document you can create scripts on the fly, dynamically:
#!/bin/shfor i in `seq 1 10`do cat <<EOS | qsub -#!/bin/sh#PBS -V#PBS -S /bin/sh#PBS -N pass_test#PBS -l nodes=1:ppn=1,walltime=00:02:00#PBS -M XXXXXX@XXX.educd /scratch/XXXXXX/pass_test./run_test $iEOSdone
Personally, I would use a more compact version:
#!/bin/shfor i in `seq 1 10`do cat <<EOS | qsub -V -S /bin/sh -N pass_test -l nodes=1:ppn=1,walltime=00:02:00 -M XXXXXX@XXX.edu -cd /scratch/XXXXXX/pass_test./run_test $iEOSdone
You can use the -F
option, as described here:
-F
Specifies the arguments that will be passed to the job script when the script is launched. The accepted syntax is:
qsub -F "myarg1 myarg2 myarg3=myarg3value" myscript2.sh
Note: Quotation marks are required. qsub will fail with an errormessage if the argument following -F is not a quoted value. Thepbs_mom server will pass the quoted value as arguments to the jobscript when it launches the script.
See also this answer
If you just need to pass numbers and run a list of jobs with the same command except the input file number, it's better to use a job array instead of a for loop as job array would have less burden on the job scheduler.
To run, you specify the file number with PBS_ARRAYID like this in the pbs file:
./run_test ${PBS_ARRAYID}
And to invoke it, on command line, type:
qsub -t 1-10 pass_test.pbs
where you can specify what array id to use after -t
option