The job script¶
The job script is a text file containing the relevant information for Slurm to schedule and run a job. Job scripts typically contain the following:
- A shell interpreter
- A resource request
- A list of commands to execute
Job script contents¶
Shell interpreter¶
All job scripts must include the shell interpreter on the first line, for
example #!/bin/bash. Omitting this line will throw the following error
during job submission:
sbatch: error: This does not look like a batch script. The first
sbatch: error: line must start with #! followed by the path to an interpreter.
sbatch: error: For instance: #!/bin/sh
Resource requests¶
Resources are specified at the top of the file using the #SBATCH <resource>
syntax. There are lots of options available, including but not limited to:
- Number of tasks (cores)
- Amount of memory
- Runtime
- GPU(s)
As a minimum, we recommend specifying the runtime and the amount of memory required for all jobs. See the sections below for more information.
We highlight common job submission options on
this page, and recommend the
official Slurm sbatch documentation
for the full list of available options.
A list of commands to execute¶
This section refers to the computation or workflow you want to run on the
cluster, such as a simulation, data analysis, or code execution. All text
after the #SBATCH lines will be interpreted as commands.
If using applications installed by us, don't forget to load the relevant module(s) before running your code.
Writing job scripts¶
We recommend that you write your job scripts using a text editor installed on the cluster. The editors we support are as follows:
vim(pre-installed, no module required)nano(preferred by beginners - requiresmodule load nanoto use)
Whilst not supported by us, we also offer emacs, via module load emacs.
No other text editor is supported on Apocrita.
Job scripts written on Windows
Job scripts transferred from a Windows PC contain invisible control
characters that will generate errors when the job runs. To prevent
such errors, convert your script to UNIX format using the dos2unix
command on the cluster. See
this page for
more information.
To open a file called example.sh, run vim example.sh or nano example.sh.
If the file exists in the current directory, it will be opened for editing,
otherwise a new, empty file will be created.