Cancel All Bosh Tasks

Sometimes, the bosh task table gets backed up with pending tasks. Maybe a stuck task created a pile-up. Or maybe your monitoring system blasted the BOSH API during an update and now you have 200 tasks all with a created_at of the Unix epoch. Who knows? That’s not what this is about. This is about getting rid of those tasks in one line with Bash, jq, and the bosh2 CLI because you have better things to do and you just want to copy-paste something into your terminal to make the pain go away.

bosh2 -e <YOURENV> tasks --json | jq .Tables[].Rows[].id -Mr | xargs -n 1 bosh2 -e <YOURENV> cancel-task
  1. Get all the tasks in a parseable format (JSON)
  2. Parse out a list of the task ids, newline-separated
  3. For each one in the list, cancel that task.

Make sure you substitute in your own environment value for the -e flag on bosh2

Now get on with your day.

Spread the word

twitter icon facebook icon linkedin icon