sbatch

The sbatch command is used for submitting jobs to the cluster. An example of a Slurm batch script (called simple.slurm) is shown below:

#!/bin/bash 

#SBATCH -N 1 

#SBATCH -c 1 

#SBATCH --mem-per-cpu=1G 

#SBATCH --time=0-00:15:00 # 30 minutes 

#SBATCH --output=my.stdout 

#SBATCH --mail-user=abac123@case.edu 

#SBATCH --mail-type=ALL 

#SBATCH --job-name="just_a_test"  

# Put commands for executing job below this line 

# This example is loading Python 2.7.8 and then 

# writing out the version of Python 

module load python 

python --version

To submit this batch script, a user would type:

sbatch simple.slurm

This job (called just_a_test) requests 1 compute node, 1 task (by default, Slurm will assign 1 CPU core per task), 1 GB of RAM per CPU core, and 15 minutes of wall time (the time required for the job to complete). Note that these are the defaults for any job, but it is good practice to include these lines in a Slurm script in case you need to request additional resources.

Optionally, any #SBATCH line may be replaced with an equivalent command-line option. For instance, the #SBATCH –ntasks=1 line could be removed and a user could specify this option from the command line using:

sbatch --ntasks=1 simple.slurm

The commands needed to execute a program must be included beneath all #SBATCH commands. Lines beginning with the # symbol (without /bin/bash or SBATCH) are comment lines that are not executed by the shell. The example above simply prints the version of Python loaded in a user’s path. It is good practice to include any module commands in your Slurm script. A real job would likely do something more complex than the example above, such as read in a Python file for processing by the Python interpreter.

Consider using the '--mail-type' flag to provide warnings about the job nearing the end of the requested timelimit. The 'ALL' option will do this, while providing many other emails for each job. To target specific conditions, review the details of using this flag at the schedmd.com documentation linked below.

For more information about sbatch see: http://slurm.schedmd.com/sbatch.html