lsf bkill all PEND jobs without killing RUN jobs
bjobs
can list just the pending jobs with -p
. It would be nice if bkill -p
would also filter jobs, so bkill -p 0
would kill all the user's pending jobs.
The best I can think of is some shell magic. While not perfect, it should cover many cases. e.g.,
bkill `bjobs -p -o jobid | grep -v ^JOBID | tr '\n' ' '`
bjobs -p -o jobid
will list the job ids of the user's pending jobs. grep -v ^JOBID
will remove the header. tr
will put it in the format that bkill
expects. One potential problem is that if the job list is too long then the max command line length or max number of command line arguments will have been exceeded, so bash will complain.
There's a small race condition here. A job could start between the query and the kill.
An alternative solution (also using shell filters as the previous answer, but without the risk of exceeding the no of allowed shell command arguments):
bjobs -w | grep 'PEND' | awk '{print $1}' | xargs bkill
Basically check for running jobs (-w wide format, no truncating), use grep
to filter PENDing job, then select jobIDs with awk
, and pass them to bkill
via xargs (xargs breaks the no of arguments passed to bkill, avoiding "Argument list too long" kind of errors).