Skip to content

Submit, inspect, and stop a job

Audience: Cluster users · Reviewed: 2026-10-04

Version and teaching scope

Use documentation matching your installed release and local policy. Check sinfo --version; upstream documentation identified itself as 26.05 at review. Paths, partitions, accounts, modules, memory, MPI, GPUs and services are site-specific. Example programs beginning ./ must already exist. These are teaching examples, not a validated deployment recipe or evidence that a cluster was modified.

Submission is not calculation success

sbatch submits a script and returns a job ID; successful submission is not successful calculation. salloc obtains an interactive allocation. srun starts a job step within an allocation, or can request resources itself. A shell opened by salloc is not universally a compute-node shell: use srun to place work on allocated resources.

A first batch job

Save this as hello.sbatch. The site must have a default partition/account, or you must add its approved options.

#!/bin/bash
#SBATCH --job-name=hello
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=1G
#SBATCH --time=00:02:00
#SBATCH --output=hello-%j.out
set -euo pipefail
printf 'job=%s submitted_from=%s\n' "$SLURM_JOB_ID" "$SLURM_SUBMIT_DIR"
srun hostname
srun date -u

Submit and inspect, replacing 12345 with the returned ID:

sbatch hello.sbatch
squeue -u "$USER"
scontrol show job 12345
sacct -j 12345 --format=JobID,JobName,State,ExitCode,Elapsed,AllocCPUS
# Only when you intend to cancel this job:
scancel 12345

Keep #SBATCH directives before executable shell lines. Shell variables in those directives are not expanded as Bash expressions. Output-directory parents must already exist. Slurm transfers the batch script, not all input files; ensure the working directory and executable are available on compute nodes.

A short interactive test

salloc --nodes=1 --ntasks=1 --cpus-per-task=1 --mem=1G --time=00:10:00
# After the allocation is granted:
srun --pty bash -l
hostname
# exit the compute shell, then exit the allocation shell when finished

Do not close an allocation without saving needed results. Avoid rapid polling loops against the scheduler. A vanished squeue entry means the job left the active queue; inspect accounting and scientific output to determine success.

Official sources

Previous: Partitions, QOS, fair share, and honest requests · Learning path · Next: Match MPI, OpenMP, and GPU execution to the application