SLURM Reference Manual
SRUN Run-Mode Options
For a strategic comparison (with examples)
of the five different ways to use SRUN,
see "SRUN Roles and Modes," above.
This section explains the mutually exclusive
SRUN options that enable its different run modes.
Each option has a one-character (UNIX) and a longer (Linux) alternative
- -b (--batch)
runs a script (whose name appears at the end of the SRUN execute line,
not as an argument to -b) in batch mode.
You cannot use -b with -A or -a.
SRUN copies the script, submits the request to run (with your specified
resource allocation) to the local SLURM-managed job queue, and
ends. When resources become available and no higher priority job is
pending, SLURM runs the script on the first node allocated to the job,
with STDIN redirected from /dev/null and STDOUT and STDERR redirected
to a file called jobname.out in the current
working directory (unless you request a different name or a more
elaborate set of output files by using -J or -o).
In other words, -b executes the script through a queue, unhooked from
terminal interaction, but not under LCRM or Moab control.
To prevent -b jobs (only) from starting over from the beginning of
their scripts in case of a machine downtime, also use --no-requeue.
(1) You must use the script's absolute pathname or a pathname relative
to the current working directory (SRUN ignores your search path).
(2) SRUN interprets the script using your default shell unless the file
begins with the character pair #! followed by the absolute pathname of
a valid shell.
(3) The script must contain MPI commands or other (simple) SRUN
commands to initiate parallel tasks.
On BlueGene/L only,
the script must invoke MPIRUN rather than simple SRUN to execute parallel
tasks (this may affect script portability).
(4) Script lines prefixed with #SLURM insert SRUN options into
the script (e.g., #SLURM --propagate); command line options
override those within the script.
- -A (uppercase, --allocate)
allocates compute resources (as specified by other SRUN options)
and starts ("spawns") a subshell that has access to those allocated
resources. No remote tasks are started.
You cannot use -A with -b or -a.
If you combine -A with the special-purpose option --no-shell, then
SRUN allocates the resources but exits instead of spawning a shell.
If you specify a script at the end of SRUN's execute line
(not as an argument to -A),
the spawned shell executes that script using the allocated resouces
(interactively, without a queue).
See the -b option for script requirements.
If you specify no script, you can then execute other instances of
SRUN interactively, within the spawned subshell, to run multiple
parallel jobs on the resources that you allocated to the subshell.
The resources (nodes, etc.) will only be freed for other jobs when
you terminate the subshell.
- (used only with -A or --allocate)
does not spawn (another) shell for --allocate mode SRUN sessions.
- -a jobid (lowercase, --attach=jobid)
attaches (or reattaches) your current SRUN session to the already
running job whose SLURM ID is jobid.
The job to which you attach must have its resources managed by SLURM,
but it can be either interactive ("allocated," started with -A)
or batch (started with -b).
This option allows you to monitor or intervene in previously started
SRUN jobs. You cannot use -a with -b or -A.
Because the running job to which you attach already has its resources
specified, you cannot use -a with -n, -N, or -c.
You can only attach to jobs for which you are the authorized owner.
By default, -a attaches to the designated job read-only.
STDOUT and STDERR are copied to the attaching SRUN, just as if the
current SRUN session had started the job.
However, signals are not forwarded to the remote processes
(and a single CTRL-C will detach the read-only SRUN from the job).
If you use -j (--join) or -s (--steal) along with -a, your SRUN session
"joins" the running job and can also forward signals to it as well
as receive STDOUT and STDERR from it.
If you join a SLURM batch (-b) job, you can send signals to its
batch script. Join (-j) does not forward STDIN, but steal (-s,
which closes other open sessions with the job) does forward STDIN as
well as signals.
- -j (lowercase, --join)
joins a running SLURM job (always used only with -a, --attach, to
specify the jobid).
This not only duplicates STDOUT and STDERR to the attaching SRUN session,
but it also forwards signals to the job's script or processes as well.
Navigation Links: [
Document List ] [
HPC Home ]