Main content blocks
Section outline
-
Typing every flag on the command line gets old. Slurm reads
#SBATCHcomment lines at the top of a script as if they were command-line flags — the script becomes self-contained and reproducible.#!/bin/bash #SBATCH --account=nn9970k #SBATCH --time=01:00 #SBATCH --mem=1G #SBATCH --job-name=hello #SBATCH --output=output-%j.txt #SBATCH --error=error-%j.txt ./example-job.shThen just
sbatch myscript.sh— the flags inside the script take effect. Anything passed on the command line still wins over an in-script directive, so you can override for one-off runs.Useful directive shortcuts:
%jin--output/--errorfilenames is replaced with the job ID.--job-name=sets the name shown insqueue.--mail-type=END,FAIL+--mail-user=…emails you when the job finishes or fails.
The quiz for this topic asks you to fill in a SBATCH script — pay attention to the unit format (Slurm accepts both
1Gand1024Mfor memory, both01:00and1:00for time).-
Fill in the SBATCH directives. This is the load-bearing exercise for this topic.
