Skip to content

Instantly share code, notes, and snippets.

@roychri
Created July 30, 2020 14:44
Show Gist options
  • Save roychri/65ab745e0fc229e1ea02e4220a169960 to your computer and use it in GitHub Desktop.
Save roychri/65ab745e0fc229e1ea02e4220a169960 to your computer and use it in GitHub Desktop.
Script that delete large amount of bull jobs using arena's API
# Script that delete large amount of bull jobs using arena's API
#
# Requirements:
# * pup (https://github.com/ericchiang/pup)
# * sed
# * tr
# * curl
#
# This was tested with BASH
PUP="./pup"
HOST="localhost"
QUEUE="myqueue"
ARENA="Server"
STATUS="completed"
# How many to delete by bulk (Affects PAGES value)
PAGE_SIZE=1000
# How many pages to delete (based on the PAGE_SIZE)
PAGES=5
for STEP in $(seq 1 ${PAGES}); do
IDS=$(curl -s "https://${HOST}/arena/${ARENA}/${QUEUE}/${STATUS}?page=1&pageSize=${PAGE_SIZE}" | \
${PUP} 'input[name="jobId"] attr{value}' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/|/","/g')
curl "https://${HOST}/arena/api/queue/${ARENA}/${QUEUE}/job/bulk" \
-H 'content-type: application/json' \
-data-binary '{"queueName":"'${QUEUE}'","action":"remove","jobs":["'${IDS}'"]}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment