Creating and Submitting Jobs¶
Write a Slurm batch script and submit it to compute nodes on Ngarrgu Tindebeek (NT), OzSTAR, or Trevor using sbatch. Compute nodes do not accept direct SSH logins unless you have an active job running on them.
Before you start¶
Connect via SSH to the login node for the cluster you want to run on (
nt.swin.edu.aufor NT,ozstar.swin.edu.aufor OzSTAR, or jump totrevorviassh trevorfrom NT or OzSTAR for Trevor). See Connecting via SSH and Swinburne HPC Systems.Store large input and output data under
/fred/<project>rather than/home. See Filesystems and Storage.Review the Policies on resource efficiency and keeping compute workloads off login nodes.
How Slurm works¶
Swinburne HPC uses Slurm to allocate compute nodes fairly across users. A Slurm batch script has two parts:
Resource requests:
#SBATCHdirectives specifying the CPUs, memory, GPUs, local scratch disk, and walltime your job requires.Commands: The module loads, environment setup, file staging, and programs your job runs once resources are allocated.
Submit your batch script to the queue with sbatch. See man sbatch or the Slurm Command Reference for a summary of available options.
Cluster and partition routing¶
By default, Slurm automatically routes each job to the cluster of the login node where you run sbatch:
tooarrana1/tooarrana2(nt.swin.edu.au) → Ngarrgu Tindebeek (NT)farnarkle1/farnarkle2(ozstar.swin.edu.au) → OzSTARtrevor(jump viassh trevorfrom NT or OzSTAR) → Trevor
You normally do not need to specify --partition — resource-specific routing (such as GPU or high-memory nodes) is handled automatically from your requested resources. For multi-cluster workflows orchestrated from a single node (for example, chaining a data-staging job on trevor to a compute job on milan), you can pass sbatch --partition=<partition> on the command line.
Write and submit a batch script¶
Every batch script must follow this order:
Line 1 — Shebang: Start the first line with the script interpreter, such as
#!/bin/bash.Next lines —
#SBATCHdirectives: Place all resource requests and Slurm options immediately below the shebang, before any shell commands.Commands: Load required modules, set environment variables, and run your application (directly for serial/OpenMP programs, or with
mpirunfor MPI programs). Define module loads and environment variables inside the batch script rather than in dotfiles so your runs stay reproducible (see Dotfiles and shell hygiene).
Save the following example as myjob.sh:
#!/bin/bash
#
#SBATCH --job-name=test
#SBATCH --output=test_%j.out
#
#SBATCH --ntasks=1
#SBATCH --time=00:10:00
#SBATCH --mem-per-cpu=200M
hostname
sleep 60
This script requests 1 CPU core (--ntasks=1) for 10 minutes (--time=00:10:00) with 200 MiB of RAM (--mem-per-cpu=200M). When the job starts, it prints the allocated compute node hostname and then sleeps for 60 seconds.
--job-name=testassigns a label shown in queue listings and the Web Job Monitor.--output=test_%j.outdirects standard output and standard error to a file where%jis replaced by the numeric Slurm Job ID.
Note
If you omit --output, Slurm writes to slurm-%j.out by default. Always keep %j (or %A_%a for job arrays) in the output filename so simultaneous jobs never write to the same file. Concurrent writes to one file from multiple nodes corrupt output and trigger Lustre lock bouncing (see Optimising Lustre I/O).
Submit myjob.sh to Slurm:
sbatch myjob.sh
Slurm confirms submission and returns your Job ID:
Submitted batch job 12345678
You can also pass Slurm options directly on the command line (for example, sbatch --time=00:30:00 myjob.sh), which overrides matching #SBATCH lines in the script. Keeping options inside your script makes experiments easier to reproduce.
Tip
A running batch script can submit follow-up jobs to Slurm by calling sbatch inside the script, which is useful for multi-stage workflows.
Verify it works and inspect output¶
Check whether your job is queued or running:
squeue --me
While a job is running, you can inspect live resource usage with the Web Job Monitor (see Monitoring and Managing Jobs).
Slurm appends output to the output file while the job runs. Replace <job_id> with the ID returned by sbatch to read the output:
cat test_<job_id>.out
Job lifecycle states¶
After you run sbatch, your job moves through these states:
PENDING(PD): The job is queued and waiting for priority or matching resources to become available.RUNNING(R): Slurm has allocated compute resources and your batch script is executing.COMPLETED(CD) orFAILED(F): The job finished cleanly with exit code0(COMPLETED), or exited with a non-zero error / exceeded a resource limit such as memory or walltime (FAILED).
Merit Allocation Scheme (MAS) projects¶
If your research group has been awarded compute time under the ASTAC Merit Allocation Scheme (MAS), specify the MAS project ID in your batch script:
#SBATCH --account=<mas_project>
Slurm automatically applies that project's ASTAC priority quality of service (QoS) and bills usage against the MAS allocation.
Also ensure your job writes output files into /fred/<mas_project> (where the directory group ID is set to the MAS project) so storage is charged to the MAS project quota, or switch your active group before submitting if required. See Accounts and Projects for project membership details.
If you are running LIGO-related jobs, you must also include a LIGO accounting tag with #SBATCH --comment=... — see Tracking LIGO Job Usage.
Parallel job models¶
The myjob.sh example above runs a serial job on a single CPU core. To use multiple cores or multiple nodes, choose the parallel model that matches your code:
Multi-process (MPI / SPMD): Multiple cooperating processes launched across one or more nodes with
mpirun. In Slurm, each process is a task requested with--ntasks.Multi-threaded (shared memory / OpenMP / pthreads): One process (
--ntasks=1) spawning multiple threads on the same compute node, requested with--cpus-per-task. Slurm never splits a single task across multiple nodes.Embarrassingly parallel (job arrays): Many independent runs of the same program across different files or parameter values using
#SBATCH --array.Hybrid (MPI + OpenMP): Multiple MPI tasks (
--ntasks), each using multiple OpenMP threads (--cpus-per-task).
For OpenMP and hybrid jobs, OMP_NUM_THREADS defaults to 1 on NT and OzSTAR. Export it in your batch script so your code uses all allocated cores per task:
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
For full resource rules (memory ceilings, multi-node core multiples, GPUs, and $JOBFS), see Requesting Resources and Interactive Jobs. For complete templates of each parallel model, see Job Script Examples.
Next steps¶
Requesting Resources and Interactive Jobs — set memory, CPU, GPU, local scratch (
$JOBFS), walltime, and interactive allocations.Job Script Examples — copy-paste scripts for serial, MPI, OpenMP, hybrid, job array, packed, and GPU workloads.
Monitoring and Managing Jobs — track job efficiency in the Web Job Monitor and command-line tools.