Created
July 30, 2020 14:44
-
-
Save roychri/65ab745e0fc229e1ea02e4220a169960 to your computer and use it in GitHub Desktop.
Script that delete large amount of bull jobs using arena's API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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