Submit Jobs to the Queue

Batch jobs are a type of non-interactive job that a user can submit to a queue. Once the requested resources are available, the batch job will automatically start running non-interactively on a compute node(s). Users do not need to be logged in or monitoring their batch jobs for them to automatically start.

Write a Batch Job Script

A batch job requires a short script with two sections. The first section (with lines beginning with #SBATCH) includes directives for the scheduler including what the job name should be, how many nodes are needed, what is the desired wall time, etc. The second section contains command-line instructions for applications to run. For example, that is where you would execute a python or matlab script.

An example minimal batch job script is as follows:

#!/bin/bash
#SBATCH -J myjob           # Job name
#SBATCH -o myjob.o%j       # Name of stdout output file
#SBATCH -p normal          # Queue (partition) name
#SBATCH -N 1               # Total # of nodes
#SBATCH -n 1               # Total # of mpi tasks
#SBATCH -t 01:30:00        # Run time (hh:mm:ss)
#SBATCH -A myproject       # Allocation name (req'd if you have more than 1)

# Other commands must follow all #SBATCH directives...

./mycode.exe

Detailed information on the acceptable parameters as well as example job scripts can be found in the User Guide for the machine you are using.

Submitting and Managing a Batch Job

Once the job script is written, you can submit a batch job to the queue with:

$ sbatch myjobscript.slurm

Monitor the status of the job with showq (pass the -u flag to only show your jobs):

$ showq -u

Jobs can be deleted if you provide the job ID:

$ scancel 123456



Return to the Overview