Slurm commands

Tip

Contact Secretariat System Administrators with HPC Questions!

Vijay Shankar

John Poole

Maria E. Adonay

vshanka@clemson.edu,jopoole@clemson.edu,madonay@clemson.edu

Contact IHG Research Cores with Research Questions!

ihgcores@clemson.edu

Attention

For a full list of commands, see the Slurm documentation.

sbatch

Consider the example script from the Batch jobs page:

 1#!/bin/bash
 2#
 3#SBATCH --job-name=fastp_ex
 4#SBATCH --cpus-per-task=1
 5#SBATCH --partition=compute
 6#SBATCH --time=00:30:00
 7#SBATCH --mem=2G
 8#SBATCH --output=/opt/ohpc/pub/workshop/toyout/logs/fastp_ex.%j.out
 9#SBATCH --error=/opt/ohpc/pub/workshop/toyout/logs/fastp_ex.%j.err
10
11# Load software
12module load fastp/0.21.0
13
14# Save directories as variables
15export dir_in="/opt/ohpc/pub/workshop/toysets/fastq/dnaseq"
16export dir_out="/opt/ohpc/pub/workshop/toyout/fastp"
17
18# Prepare directories
19mkdir -p ${dir_out}
20cd ${dir_in}
21
22# Execute function for each fastq file
23# Note: This example is for paired-end data
24for r1 in *_R1_001.fastq.gz
25do
26   r2="$(echo ${r1} | sed -e 's/R1/R2/')"
27   prefix="$(echo ${r1} | cut -f1-3 -d'_')"
28
29   fastp \
30      -in1 ${dir_in}/${r1} \
31      -in2 ${dir_in}/${r2} \
32      -out1 ${dir_out}/${prefix}_R1.out \
33      -out2 ${dir_out}/${prefix}_R2.out \
34      --json ${dir_out}/${prefix}.json \
35      --html ${dir_out}/${prefix}.html
36done

Say that we saved this code to a file named fastp_ex.sh. We would then submit the script by running the following commands from the command line:

cd /path/to/fastp_ex.sh
sbatch fastp_ex.sh

The sbatch command submits the script to Slurm, which allocates the appropriate resources (specified in the sbatch header of the script) from Secretariat to complete the job. Once successfully submitted, the job is assigned a job ID.

The following message should print to the terminal window:

Submitted batch job [job_id_number]

where [job_id_number] is a number greater than or equal to 1.

squeue

To review all of the currently submitted jobs, their IDs, and other information, run the squeue command from the command line. This command will output a table with the following header:

JOBID

PARTITION

NAME

USER

ST

TIME

NODES

NODELIST(REASON)

where

  • JOBID: ID number assigned to job

  • PARTITION: partition to which job has been assigned

  • NAME: name of job specified in sbatch header with --job-name

  • USER: username of the user who submitted the job

  • ST: status of job (for more information, see the Squeue status codes page)

  • TIME: amount of time the job has been running

  • NODES: number of unique nodes that the job is assigned to

  • NODELIST(REASON): node(s) the job is assigned to

scancel

If you need to terminate a specific job before it has completed, run the following from the command line:

Attention

The command scancel is final and cannot be undone. Use with caution.

scancel [job_id_number]

If you need to terminate all of your currently submitted jobs, run the following from the command line:

scancel -u [username]

where [username] is your username.

Attention

Do not include the brackets (“[” and “]”) when substituting your job_id_number and username.