sbatch¶
Submit a batch script to Slurm. A Slurm batch script is a normal shell script, usually containing multiple calls to srun
. The script can be scheduled for (non-interactive) execution with the sbatch
command. There are a lot of options to sbatch
which can be given on the command line or (preferable) specified at beginning of the script using a #SBATCH
directive. A complete list of options and some examples are documented in the sbatch
man page.
A typical Slurm job submission script looks like this:
#!/bin/bash
# general parameters
#SBATCH --job-name="my job"
#SBATCH --output="my_job.txt"
# resource parameters
#SBATCH --mem-per-cpu=200M
#SBATCH --time=30:00
# job steps
echo "[$(date)] staring my job"
srun --partition test my_job < my_data
echo "[$(date)] all done"
`#SBATCH` can only be used at the beginning of a script. The parsing of `#SBATCH` directives is stopped at the first non-comment line.
Examples¶
Options¶
sbatch --time=10 foo.sh
#!/bin/bash
#SBATCH --mail-user=cnetid@cs.uchicago.edu
#SBATCH --mail-type=ALL
#SBATCH --output=/home/cnetid/slurm/out/%j.%N.stdout
#SBATCH --error=/home/cnetid/slurm/out/%j.%N.stderr
#SBATCH --chdir=/home/cnetid/slurm
#SBATCH --partition=debug
#SBATCH --job-name=check_hostname_of_node
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=500
#SBATCH --time=15:00