Job Scripts

To submit a job to the cluster requires a job script. This is a shell script which uses special commands to define the task to be run and the resources required. The commands in the script execute programs as if they are being run through a terminal. As the job will be run by the queuing system, the programs must execute without requiring interaction with the user (so you cannot run a graphical application from a job script). Specifying resources requires some prior knowledge or experience of the task and its requirements.

An example of a job script, showing the essential components, is given below:

#!/bin/bash
#SBATCH --ntasks=1
#SBATCH --mem=8000MB
#SBATCH --time=06:00:00
#SBATCH --job-name=myjob1
#SBATCH --partition=short
./mycode

This should be saved as a text file. It is convenient to use a file extension, such as .slr, to remind us that it is a SLURM job script – for example, myjob.slr. The --ntasks parameter indicates how many CPU cores on the compute node should be used to run the task. If your program is not parallelised, this should be 1. The --mem parameter specifies the total amount of memory required for the job, while the --time parameter specifies the expected time the job will take to run (wall time). If your job exceeds this wall time, it will be terminated.

The --job-name parameter is optional, but allows you to easily distinguish between jobs when you submit multiple jobs at the same time.

The --partition parameter specifies the Partitions (queue) to use.

The line ./mycode is a shell command which executes the mycode executable in the current working directory. The current working directory will initially be the path from where the job script is submitted.