Information Technology
How do I Force Jobs to Run in Sequence?

10-Apr-2007


Introduction

Occasionally it might be required for your jobs to run in a particular sequence. PBSPro version 7 and higher supports a feature called block=true which will allow you to run multiple jobs with each job waiting on the previous job to terminate before the next job starts. This feature existed on Ada prior to September, 2006. At that point we switched to the Torque/Moab resource manager and job scheduler combination which does not support this feature. This document will describe how to use a similar feature in the Torque resource manager.


Use depends=afterok feature

In order to get a job to wait (block) and not run until another job has completed successfully, you must use the PBS feature called depends=afterok. For example, assume your first job was submitted to PBS and it was assigned the jobID of 89980.ada759-6.ada.rice.edu. You can now force a second job to run after the first one completes successfully by specifying the option -W depends=afterok:firstjobid as follows:


qsub -W depends=afterok:89980.ada759-6.ada.rice.edu mypbs.jobscript

Using this option, the second job will be put on 'Hold' state until the first job, 89980.ada759-6.ada.rice.edu, completes successfully. Submitting multiple jobs in an automated fashion will require some scripting (i.e. bash, tcsh, perl) to run the qsub command in a loop while trapping the jobID of each job into a variable. This variable can then be used to represent the jobID in subsequent calls to qsub. The technical details of a script like this are beyond the scope of this document.

IT
Division of Information Technology
MS-119, P.O. Box 1892, Rice University, Houston, Texas 77251-1892
713-348-HELP(4357)