Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
script to cancel all pulp tasks
#!/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
@aurelien-git

This comment has been minimized.

Copy link

@aurelien-git aurelien-git commented Sep 19, 2016

works like a charm, thanks!

@mrjoshuap

This comment has been minimized.

Copy link

@mrjoshuap mrjoshuap commented Nov 15, 2016

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