Batch Jobs

A batch job is a job that will be executed without user interaction. The steps to be done are defined in a “batch script”, which also contains notations of what resources are required to run the job. When a cluster system provisions and then reserves resources for a batch job, Slurm runs the batch script on the user’s behalf, which directs (and potentially montiors) the computational work, and exits when the work is done.

Use batch jobs for workflows that are debugged, ready to run, and don’t require interaction. For mixed resource heterogeneous jobs, see the Slurm heterogeneous jobs documentation.

sbatch

Batch jobs are submitted as a job script (as in the Sample Jobs Scripts) using the sbatch command. Job scripts usually start with a series of Slurm directives that describe requirements of the job, such as number of nodes and wall time required, to the batch system/scheduler. Slurm directives can also be specified as options on the sbatch command line; command line options take precedence over those in the script. The rest of the batch script consists of user commands.

The syntax for submitting a batch job with sbatch is:

sbatch [list of sbatch options] script_name
main sbatch options

Option

Description

--time=time

time = maximum wall clock time (d-hh:mm:ss) [default: 30 minutes]

--nodes=n

Total number of nodes for the batch job.

n = number of 64-core nodes [default: 1 node]

--ntasks=p

Total number of cores for the batch job.

p = number of cores per job to use (1 - 64) [default: 1 core]

--ntasks-per-node=p

Number of cores per node.

p = number of cores per node to use (1 - 64) [default: 1 core]

Example:

--time=00:30:00
--nodes=2
--ntasks=32

or

--time=00:30:00
--nodes=2
--ntasks-per-node=16

See the sbatch page at SchedMD for additional information.

Useful Batch Job Environment Variables

useful batch job environment variables

Description

Slurm Environment Variable

Detail Description

Array JobID

$SLURM_ARRAY_JOB_ID

$SLURM_ARRAY_TASK_ID

Each member of a job array is assigned a unique identifier.

Job Submission Directory

$SLURM_SUBMIT_DIR

By default, jobs start in the directory that the job was submitted

from. So the “cd $SLURM_SUBMIT_DIR” command is not needed.

JobID

$SLURM_JOB_ID

Job identifier assigned to the job.

Machine(node) list

$SLURM_NODELIST

Variable name that contains the list of nodes assigned to the batch job.

See the sbatch man page for additional environment variables available.