Skip to content

Getting Started

Exercises

  1. Write and submit a simple job script

Create a file called first_job.sh that prints the hostname, the current date, and your username. Include #SBATCH directives for job name, output file, time limit (5 minutes), 1 task, and 1G of memory. Submit it with sbatch.

Hint / Solution
cat > first_job.sh << 'EOF'
#!/bin/bash
#SBATCH --job-name=first_job
#SBATCH --output=first_job_%j.out
#SBATCH --time=00:05:00
#SBATCH --ntasks=1
#SBATCH --mem=1G

echo "Hostname: $(hostname)"
echo "Date: $(date)"
echo "User: $USER"
EOF

sbatch first_job.sh
Expected output: Validated 2026-04-15 on slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ sbatch first_job.sh
Submitted batch job 42
  1. Check your job status

After submitting the job above, use squeue to check whether your job is pending or running. Note the job ID, state, and which node it was assigned to.

Hint / Solution
squeue --me
Expected output: Validated 2026-04-15 on slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ squeue --me
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
  1. Find and read the output file

Once the job completes (it should finish quickly), find the output file and display its contents. The filename pattern includes the job ID.

Hint / Solution
# List matching output files
ls first_job_*.out

# Read the most recent one
cat first_job_<jobid>.out
Expected output: Validated 2026-04-15 on slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ ls gs3_*.out
gs3_42.out

$ cat gs3_42.out
Hello from batch-dy-compute-1
  1. Check job accounting after completion

Use sacct to look up your completed job. Display the job ID, job name, elapsed time, state, and exit code.

Hint / Solution
sacct -j <jobid> --format=JobID,JobName,Elapsed,State,ExitCode
Expected output: Validated 2026-04-15 on slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ sacct -j 42 --format=JobID,JobName,Elapsed,State,ExitCode
JobID           JobName    Elapsed      State ExitCode 
------------ ---------- ---------- ---------- -------- 
42             val_gs4   00:00:01  COMPLETED      0:0 
42.batch         batch   00:00:01  COMPLETED      0:0 
  1. Explore the cluster

Use sinfo to determine how many partitions are available, which partition is the default, and what the maximum time limit is for each partition.

Hint / Solution
sinfo
The default partition is marked with `*` in the PARTITION column. The TIMELIMIT column shows the maximum walltime for each partition. Expected output: Validated 2026-04-15 on slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
$ sinfo
PARTITION AVAIL  TIMELIMIT  NODES  STATE NODELIST
batch*       up   infinite      2  idle~ batch-dy-compute-[3-4]
batch*       up   infinite      2   idle batch-dy-compute-[1-2]
debug        up   infinite      1  idle% debug-dy-small-2
debug        up   infinite      1  idle~ debug-dy-small-1
gpu          up   infinite      1  idle~ gpu-dy-t4-1
highmem      up   infinite      1  idle~ highmem-dy-large-1

References