Last active
June 21, 2019 12:54
-
-
Save snobear/16c42b19455ffe3ab83e to your computer and use it in GitHub Desktop.
script to cancel all pulp tasks
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
#!/bin/bash | |
# | |
# Cancel all pulp tasks that are just in a specifiedstate | |
tmpfile=/tmp/tasks | |
read -p "Enter task state to kill, e.g. Waiting: " ans | |
echo "" | |
if [ "${#ans}" -gt 0 ] | |
then | |
task_type=$ans | |
fi | |
echo -- Dumping the full list of pulp server tasks to $tmpfile... | |
# boolean - should this task be cancelled? | |
cancel_task=0 | |
task_id=0 | |
pulp-admin tasks list | egrep 'State|Task Id' > $tmpfile | |
while read line | |
do | |
if [ $cancel_task -eq 1 ]; | |
then | |
task_id=`echo $line | cut -d':' -f2 | tr -d ' '` | |
#echo $task_id | |
# fire cancel command | |
pulp-admin tasks cancel --task-id $task_id | |
# reset | |
cancel_task=0 | |
fi | |
# the next line will have the task ID | |
if [[ $line =~ $task_type ]]; | |
then | |
cancel_task=1 | |
fi | |
done < $tmpfile |
Agreed, worked perfectly for me! This was handy when I had stuck pulp tasks after mongodb ran out of disk space! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works like a charm, thanks!