Kill all jobs with a name

Author
Published

April 7, 2016

I had some jobs waiting in queue with non-consecutive job id numbers, but all with the same job name. Mistakes were made and they needed killing. A solution would be to copy-paste all the relevant job IDs and go:

bkill 1001 1002 1030

But where is the fun in that? (Not mention that mistake could have been made and unintended jobs might have been canceled).

Solution

How to kill all jobs in queue with a certain name:

j=`bjobs | grep bam2bw | awk '{print $1}'`
bkill $j

grep will capture the jobs with a particular name, also using patters if needed, and awk will print the column with the job ids. awk could have also been used to capture the relevant jobs, but I feel more comfortable using grep.

Reuse

Citation

BibTeX citation:
@online{domingues2016,
  author = {Domingues, António},
  title = {Kill All Jobs with a Name},
  date = {2016-04-07},
  url = {https://amjdomingues.com/posts/2016-05-01-kill-bsub-jobs/},
  langid = {en}
}
For attribution, please cite this work as:
Domingues, António. 2016. “Kill All Jobs with a Name.” April 7, 2016. https://amjdomingues.com/posts/2016-05-01-kill-bsub-jobs/.