NAME

waitjobs - Wait for selected jobs to exit the queue

VERSION

version 0.24.0

SYNOPSIS

waitjobs [options] [job_name]

DESCRIPTION

This script waits for selected jobs to exit the queue. It continuously checks the status of the jobs and waits until all the specified jobs are completed.

OPTIONS

-u, --user <username>

Specify the username to wait for jobs from. By default, it uses the current user.

-n, --name <pattern>

Specify the name pattern (a regular expression) to filter the jobs. Only jobs with matching names will be considered. The default pattern is '.+' (matches any name). The name can also be supplied as a positional [job_name] argument; when both are given, the positional argument takes precedence.

-s, --status <state>

Only wait for jobs in the given SLURM state. The state must be a SLURM short code, for example R (running), PD (pending) or CG (completing); passing a full name such as RUNNING is not accepted. By default jobs in any state are matched.

-r, --refresh <time>

Specify the refresh time in seconds for checking the job status. The script will wait for this duration before checking the job status again. The default refresh time is 20 seconds.

-S, --submit

Instead of waiting in the foreground, submit this very waitjobs invocation as a small SLURM job (1 core, 4GB of memory) that performs the waiting, then exit immediately after printing the submitted job id to standard output. This is useful to make a downstream job depend on a set of jobs finishing, e.g.

JOBID=$(waitjobs -n concat -S)
runjob --after $JOBID -r "next_step.sh"

The submitted command is rebuilt from the parsed options (user, name, status and refresh), so it never carries --submit and cannot resubmit itself in a loop. The queue, temporary directory and other defaults are taken from ~/.nbislurm.config, exactly as for runjob.

--jobname <name>

Override the name given to the submitted waiter job. By default the name is derived from the --name pattern as wait-<name> (for example -n concat gives wait-concat); when no specific name is requested the job is called wait-all. Only meaningful together with --submit.

-T, --jobtime <time>

Walltime for the submitted waiter job, as a time string such as 2h, 1d or 2d 12h. The default is 1d, chosen so the waiter outlives the jobs it is watching. Only meaningful together with --submit.

--verbose

Display verbose output, including the number of jobs being waited for at each refresh.

--debug

Enable debug mode, printing the list of job ids currently being tracked at each refresh.

--help

Print the help message and exit.

EXAMPLES

Example 1:

Wait for all your jobs with a specific name to exit the queue:

waitjobs -n myjob
Example 2:

Wait for jobs from a specific user to exit the queue:

waitjobs -u username
Example 3:

Wait for jobs with a specific name from a specific user:

waitjobs -u username -n myjob
Example 4:

Wait only for running jobs with a specific name, refreshing every 10 seconds:

waitjobs -n myjob -r 10 -u username -s R
Example 5:

Pass the job name as a positional argument instead of -n:

waitjobs myjob
Example 6:

Submit the waiter itself to SLURM and capture its job id so another job can depend on it (the waiter is named wait-concat and allowed up to two days):

JOBID=$(waitjobs -n concat -S -T 2d)
runjob --after $JOBID -r "launch-coassembly.sh"

AUTHOR

Andrea Telatin <proch@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2023-2025 by Andrea Telatin.

This is free software, licensed under:

The MIT (X11) License