I know that for a specific job ID, I can use scontrol hold $JOBID
.
How can I hold jobs for several IDs or/and hold jobs for a range of jobs ids (e.g. scontrol hold 294724-294749)?
Also, how can I hold jobs based on my $USER
?
First off, if all your jobs have the same name, you can use
scontrol hold <jobname>
to hold them all.
But the scontrol
command accepts a list of job IDs, which can be either space- or comma-separated. So if your jobs have consecutive job IDs, you can use Bash's {1..n}
(Brace expansion) construct to generate the list and feed it to scontrol:
scontrol hold {294724..294749}
Otherwise, one common idiom is to use squeue
's output formatting capabilities to generate scontrol
commands and feed them to a shell:
squeue --noheader --user $USER --format "scontrol hold %i" | sh
(When doing that, it is wise to first run the squeue command without piping to sh
to review its output before running it again through sh
)