Slurm
The Slurm script generally follows this format:
#!/bin/bash # Declaring Slurm Configuration Options # Loading Software/Libraries # Running Code
.1. Sample Slurm Script
For example, let’s create a sample Slurm job script and submit the job to the cluster. First, create an empty file using vim editor(or your favourite editor) and insert the following script and save it using .slurm or .sh extension (for example, myjob.slurm or myjob.sh):
#!/bin/bash #SBATCH --job-name=myjob # Name for your job #SBATCH --comment="Run My Job" # Comment for your job #SBATCH --output=%x_%j.out # Output file #SBATCH --error=%x_%j.err # Error file #SBATCH --time=0-00:05:00 # Time limit #SBATCH --nodes=1 # How many nodes to run on #SBATCH --ntasks=2 # How many tasks per node #SBATCH --cpus-per-task=2 # Number of CPUs per task #SBATCH --mem-per-cpu=10g # Memory per CPU #SBATCH --qos=short # priority/quality of service # Command to run hostname # Run the command hostname
In this example, we run the bash command hostname.
.2. To submit this job, run:
sbatch myjob.slurm
This will submit your job to the Slurm for execution and a message with Job_ID will be displayed.
$ sbatch myjob.slurm Submitted batch job 3113275 on cluster nautilus
.3. You can check the status of your jobs using
The command
squeue -u $USER
or the equivalent :
squeue --me
For this example, one gets :
$ squ Fri Dec 15 15:13:26 2023 CLUSTER: nautilus JOBID PARTITION NAME USER STATE TIME TIME_LIMI NODES NODELIST(REASON) 3113275 all myjob <login> RUNNING 0:00 5:00 1 cnode328 CLUSTER: waves JOBID PARTITION NAME USER STATE TIME TIME_LIMI NODES NODELIST(REASON)
.4. To obtain complete information about a job (allocated resources and execution status), run:
scontrol show job $Job_ID
.5. To cancel a job, run:
scancel $Job_ID
For more information, please check the official documentation of Slurm.