Artificial intelligent assistant

lsf bkill all PEND jobs without killing RUN jobs I'v lots bjobs running on lsf, jobs have two status, RUN and PEND. And I want to kill all bjobs with PEND status, how to do that use script? A hard-coded way I think is saving them in a file then parse every line to get the status and key. If the STAT is PEND then pass the key to `bkill $key`. But this is very complicated, is there any bkill function that can directly do this or a non hard-coded way to kill jobs with a specific status or name?

`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 id -noheader | tr '\
' ' '`


`bjobs -p -o id -noheader` lists the job ids of the user's pending jobs. `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.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy cdc36f7e98061687c65972c17803e58c