skip to main content

Using PBS Variables

Many PBS jobs are very similar to each other, differing from previous jobs only by one or two parameters, like input filename. PBS allows scripts to use input parameters so scripts don’t have to be rewritten for every job.

An example job that demonstrates this is available on Maple at /usr/local/apps/example_jobs/pbs_variable_example

The main file is variable_example.pbs:
#PBS -N variable
#PBS -l mem=2gb
#PBS -l ncpus=1


echo "Input file: $INPUT_FILE"

# Run program here

The variable in this example is called INPUT_FILE. First, the script changes to the directory from which the script was submitted. Then it echos the value of the variable passed into the script. Finally, it runs a program on the input file, in this case, just ls.

This PBS script can be submitted by running:
qsub -v INPUT_FILE=file.csv variable_example.pbs

Starting multiple jobs at once

With some shell scripting, multiple jobs can be started at once. For instance, assume you had multiple CSV files that all needed to be processed by the same program. You could submit a separate for for each one by running:

for file in *.csv
qsub -vINPUT_FILE=$file variable_example.pbs

This code is included as in the example job on Maple.