.. _scheduler-submitjobs: ************ Running Jobs ************ .. _slurm-batch-job: Batch jobs (sbatch) =================== ``sbatch`` is a slurm command which submits a batch job to the queue. You can pass a job script or job recipe as a file to the command, or, if no file name is given, ``sbatch`` reads the script from standard input. A batch script can include options preceded by ``#SBATCH`` lines before any executable commands. ``sbatch`` stops processing ``#SBATCH`` directives after the first non-comment, non-whitespace line. .. _slurm-job-scripts: Job scripts ----------- A job script (also called a submit file) is a plain text file where you request cluster resources and list, in order, the commands you want to run. The script is passed to ``sbatch``, which submits it to the Slurm scheduler. Below is a Slurm job script example. The file name used in this example is ``slurm_test.sub``. Job Example ^^^^^^^^^^^ .. code-block:: slurm :caption: Example submit script that runs a helloworld program #!/bin/bash #SBATCH --partition=main #Selecting the partition #SBATCH --job-name="hello" #Name of job (displayed in squeue) #SBATCH --nodes=1 #Number of nodes #SBATCH --ntasks-per-node=10 #Number of tasks per node #SBATCH --time=00:05:00 #Maximum time for job to run #SBATCH --mem=2G #Memory per node #SBATCH --output=slurm.%N.%j.out #Output file for stdout (optional) #SBATCH --error=slurm.%N.%j.err #Error file for stderr (optional) cd $SLURM_SUBMIT_DIR #Change to submission directory conda activate myenv #activate conda env python helloworld.py #Run python file The ``#SBATCH`` directives in your job script define the resources requested for compute jobs. Use only the options you need to describe your requirements. If you do not specify resources using ``#SBATCH``, standard defaults are assigned to the job. ``#SBATCH`` lines must appear at the top of the script with no blank lines between them. The general format is: ``#SBATCH --