Body
When to Use?
SLURM (Simple Linux Utility for Resource Management) is a popular job scheduler used in many high-performance computing (HPC) environments. This guide will help you submit a basic job script in SLURM.
Steps to Submit a Basic Job
Create a Job Script
A job script is a shell script containing SLURM directives and the commands to run your job. Use the example below to create a basic file:
nano myfirstjob.sh
You will then get a new window that pops up copy and paste the code below into your file:
#!/bin/bash
#SBATCH --job-name=my_job # Job name
#SBATCH --output=output_%j.txt # Output file name (%j expands to jobID)
#SBATCH --time=01:00:00 # Time limit (hh:mm:ss)
#SBATCH --ntasks=1 # Number of tasks
#SBATCH --cpus-per-task=1 # Number of CPU cores per task
#SBATCH --mem=1G # Memory per node
#SBATCH --partition=short # Partition name
# Load any necessary modules
# Commands to execute your job
echo “My First Job”
sleep 10
Save the Job Script
Save the file by hitting the ctrl key and the x key. Then hit the y key and then the enter key
Submit the Job Script
Submit the job to SLURM using the sbatch
command:
sbatch myfirstjob.sh
After submission, SLURM will return a job ID, which you can use to track the job.
Check Job Status
To check the status of your job, use the squeue
command along with your username:
squeue -u your_username
This will list all your jobs along with their current statuses.
View Job Output
After the job completes, you can view the output and error files specified in your job script (output_%j.txt). You can use the cat command to display your output file (Note: your job id number will be different than what is in the command below).
cat output_1275.txt