A basic job
Before you start
To run a job you will need:
- Research data on the cluster
- An application to run
- Your login credentials
- A text editor —
nanois a good choice if you are new to the command line
Make sure you are logged in before continuing. If you are new to SLURM, the SLURM documentation is a useful reference.
The job script and sbatch
You submit a program to SLURM for execution using the sbatch command. The easiest way to do this is with a job script (also called a job description file).
A minimal job script looks like this:
Write this to a file — in the examples below it is named echo_script.sh, but any name will do. Submit it with sbatch:
You should see output similar to:
SLURM assigns the job a number (7185 here). Once the job has run, you will find a file named slurm-7185.out in your working directory containing the program's output and any error messages.
The three parts of a job script
The echo_script.sh example shows the three sections every job script must have:
- Shell specification — the
#!/bin/bashline tells the system which shell to use - Resource statement(s) — lines starting with
#SBATCHdeclare what resources the job needs; here-t 00:05:00requests 5 minutes of compute time. If the job has not finished by then, SLURM will terminate it. - Body — the UNIX commands to run; a job script is a normal shell script, so anything valid in bash is valid here
Real job scripts typically include several #SBATCH lines to specify things like the number of cores, memory, and a job name. These are covered in Specifying job requirements.
Author: (LUNARC)
Last Updated: 2022-10-05