Using PBS

From Athena Wiki
Jump to: navigation, search

Submit PBS script

To submit a script, you will need a shell program to give to qsub. Here is a sample:


    #PBS -q default

DAY=`date +"%a %B %d, %Y"`
TIME=`date +"%r %Z"`

echo "Hello from `hostname` on $DAY at $TIME"

Save this in a file, such as

The script can then be submitted to the grid with qsub.


If your jobs is submitted successfully, qsub will print the the name of the job:

When the jobs runs, two output files will be created: and (where 1234 will be the job id number). These correspond to the standard output and standard error pipes from your program. For the script above, should be empty (no errors), and will contain a line something like:

Hello from on Tue May 13, 2014 at 11:44:05 AM EDT

A somewhat more complicated example, using MPI appears below:


    #PBS -q default
    #PBS -l nodes=2:ppn=12

mpiexec -machinefile /opt/machinelist -n 10 PROGRAM ARGUMENTS

echo "end"

Replace the PROGRAM and ARGUMENTS with your own Unix program and command-line arguments.

Save this in a file, such as /home/dblank/pbs/

PBS is a language that allows you to set many aspects of your running program. For more details see ...

In this example, we tell mpiexec to choose from the machines listed in /opt/machinelist (all of the nodes) and to create 2 instances of our running code across those machines.

NOTE: the program will start in your home directory, so by default you will be in /home/dblank/. Use full pathnames to /data1/ for shared data.

NOTE: the results of qsub will appear here. Therefore, you may want to move your shell script to a folder before beginning.

Another example:


    #PBS -l walltime=00:1:00
    #PBS -l nice=19
    #PBS -q default
    #PBS -l nodes=1:ppn=12
    #PBS -t 0-14


echo $x squared is $(($x * $x))
echo The square root of $x is $(echo "sqrt ( $x )" | bc -l)

echo "end"

Check status

When PBS starts your program a number of things will happen:

  1. your program will be scheduled to run
  2. when qsub runs your script, the script be submitted to each of the machines, perhaps a number of times

You can run "qstat -a" to see the status of your program.

Other Q Commands

  • qdel
  • qalter
  • qholde
  • qrls