Advanced SGE: Job Dependencies

The SGE scheduler allows you to submit a job but then hold them in the queue until certain job dependencies are met, ie. it will hold the job until a previous job (or number of jobs have completed).

To do this, submit the first job as normal:

$ qsub

As usual, the scheduler will give you a job ID <jobid> .

if you then want to submit another job that is dependent on the first one completing, use the -hold_jid option for qsub:

$ qsub -hold_jid <jobid>

Job 2 will remain in the queue until job 1 has completed.

Alternatively, if you have given the job a name (using the -N option), then you can put a hold on subsequent jobs using the name instead:

$ qsub -hold_jid <jobname>

If you give several jobs the same name, then the job will be held until all the named jobs have been completed.