You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Job Directives

Any shell script can be submitted as a Slurm job with no modifications. In such a case, sensible default values will be applied to the job. However, you can configure the script to fit your needs through job directives. In Slurm, these are just special comments in your script, usually at the top just after the shebang line, with the form:

#SBATCH option=value

Note that these directives:

  • start with the #SBATCH prefix
  • are always lowercase
  • have no spaces in between.
  • don't expand shell variables (they are just shell comments)

A Slurm job might look like the following:

#!/bin/bash
# The job name
#SBATCH --job-name=helloworld
# Set the error and output files
#SBATCH --output=hello-%J.out
#SBATCH --error=hello-%J.out
# Set the initial working directory
#SBATCH --workdir=/scratch/us/usxa
# Choose the queue
#SBATCH -–qos=express
# Wall clock time limit
#SBATCH --time=00:05:00
# Send an email on failure
#SBATCH --mail-type=FAIL
# This is the job
echo “Hello World!”
sleep 30

This table describes the most common options you can use in a Slurm job:

DirectiveDescriptionDefault
--job-name=...A descriptive name of the jobScript name
--output=...      Path to the file where standard output is redirected. Special placeholders for job id (%j) and the execution node (%N)slurm-%j.out
--error=...Path to the file where standard error is redirected. Special placeholders for job id (%j) and the execution node (%N)output value
--workdir=...Working directory of the job. The output and error files can be defined relative to this directorysubmitting directory
--qos=...Quality of Service (or queue) where the job is to be submittednormal
--time=...

Wall clock limit of the job. Note that this is not cpu time limit

The format can be: m, m:s, h:m:s, d-h, d-h:m or d-h:m:s

qos default time limit
--mail-type=...Notify user by email when certain event types occur. Valid values are: BEGIN, END, FAIL, REQUEUE and ALLdisabled
--mail-user=...email address to send the emailsubmitting user
--ntasks=..Allocate resources for the specified number of parallel tasks. Note that a job requesting more than one must be submitted to a parallel queue. There might not be any parallel queue configured on the cluster1

You can also use these options as command line arguments to sbatch.

Job variables

Inside a job,  you can benefit from some variables defined by SLURM automatically. Some examples are:

  • SLURM_JOBID
  • SLURM_NODELIST
  • SLURM_SUBMIT_DIR

 

 

 

  • No labels