Example PBS Script
This page explains the PBS script used on the Running an example job page. Lines of the script are in a
fixed width font and bold. Explanation is in a variable width font.
The PBS script is essentially split into two parts. “Administrative” information begins with
#PBS. This is the first half of the script. The second half of the script is a bash script (though it could be tcsh, Python, etc.). It contains the commands that are actually run.
This line is not necessary for our purposes, but could be useful if running the script outside PBS.
#PBS -N prime
This line defines the name of the PBS job.
#PBS -j oe
This line tells PBS to combine the output and error output streams into a single file. This is more useful and convenient than the default.
#PBS -l ncpus=1
This tells PBS that a single CPU core is needed. This is the default. Specifying more than one CPU doesn’t automatically make your program use more than one CPU. There is usually some application-specific way of telling your program how many CPUs to use.
#PBS -l mem=1gb
This tells PBS how much memory is required for the job. You should slightly overestimate, as jobs using more memory than specified will be killed automatically by PBS.
#PBS -m abe
This tells PBS to email you when the job aborts, begins, or ends.
#PBS -M email@example.com
This line specifies which email the emails above should be sent to. By default they are sent to the user’s system mailbox, which is not convenient for most users.
module load python
This begins the list of commands needed to actually run the job. This line loads the system’s Python module, which is an installation of Anaconda Python. Many other modules are available. Most commonly, modules simply modify your
PATH or other environmental variables.
This line is needed for almost every PBS script. When a job begins its execution, its current directory is the user’s home directory. This line changes the current directory to the directory from which the job was submitted. It utilizes an environmental variable that is set by PBS. There are several other environmental variables set by PBS, all of which can be seen in the job’s
qstat -f output.
This line runs the Python script in the current directory. It also uses the bash shell’s
time utility to keep up with how long it takes to run the Python script.
That’s it. If you need assistance modifying an example PBS script or writing one from scratch, please contact the MCSR staff.