A job script file is a simple shell script file (typically using the bash UNIX/Linux shell) which contains some information for SLURM (although you can use the command line to override behaviour) and then any commands you need to run your job, such as file preparation, changing directories and running the actual command.
Many examples for specific cases are given in other sections.
A script is of the general form:
#!/bin/bash -l #SBATCH sbatchcommand1 #SBATCH sbatchcommand2 #SBATCH sbatchcommand... #SBATCH sbatchcommandn load modules here required for your job some shell script commands to run your job
In the above the
sbatchcommand1 is a command
as you would type for
on the command
line, and there may be between 0 and n of these. This is then followed by
the commands necessary to run your work, such as
mpirun of a parallel program.
A simple example would be:
#!/bin/bash -l #SBATCH --partition=compute-12 #SBATCH --job-name=ajob #SBATCH --time=10:00:00 #SBATCH --nodes=1 #SBATCH --account=myaccount module purge module load somepackage/0.1 somepackage 1 2 3
Below this is analysed line-by-line.
Here the first line makes sure that the shell being used to run the programs is bash and that it pickups up a basic login environment.
The second line specifies a partition (see Partitions ) that in this case specifies that the job will run on the 12 core nodes.
The third line tells the system to call the job ajob for use when Job Monitoring .
The fourth line indicates that the job has a maximum run time of 10 hours.
The fifth line specifies that the number of nodes it will use is 1. Bear in mind it will use the whole node (see Node Exclusivity ) and the way SLURM allocates CPUs and nodes (see Nodes, CPUs, tasks ). For this reason you should ensure that your job can use all 12 cores and take care with Small Jobs .
The sixth line specifies the account to charge usage to. Replace myaccount with the one you have been asssigned, which is of the form
SLURM inherits the environment you submitted the job with so this ensures that no stray software modules (see Environment Module ) are loaded, but be careful with stray environment variables.
module load somepackage/0.1
Loads the module associated with the fictional package somepackage. Load none, one or more required packages here.
somepackage 1 2 3
Run the fictional package somepackage with parameters. You may need different parameters, or to let some packages know how many cores are available, and so on. Examples for commercial packages are given, and examples for various other options such as common ways to run parallel programs elsewhere in the documentation.
Note you can run several commands in sequence in this section of the script.