Getting Started
Exercises¶
- 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
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
- 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
Expected output: Validated 2026-04-15 onslurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
- 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
slurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
- 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
Expected output: Validated 2026-04-15 onslurm-training-val (Slurm 25.11.4, ParallelCluster 3.15.0).
- 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
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 onslurm-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