Skip to content

Instantly share code, notes, and snippets.

@avovsya
Created August 13, 2014 12:44
Show Gist options
  • Save avovsya/60c04018bcf999b6a32d to your computer and use it in GitHub Desktop.
Save avovsya/60c04018bcf999b6a32d to your computer and use it in GitHub Desktop.
Script to delete RabbitMQ queues by pattern. Took from http://stackoverflow.com/a/18785918/1130863
for word in "$@"
do
args=true
newQueues=$(rabbitmqctl list_queues name | grep "$word")
queues="$queues
$newQueues"
done
if [ $# -eq 0 ]; then
queues=$(rabbitmqctl list_queues name | grep -v "\.\.\.")
fi
queues=$(echo "$queues" | sed '/^[[:space:]]*$/d')
if [ "x$queues" == "x" ]; then
echo "No queues to delete, giving up."
exit 0
fi
read -p "Deleting the following queues:
${queues}
[CTRL+C quit | ENTER proceed]
"
while read -r line; do
rabbitmqadmin delete queue name="$line"
done <<< "$queues"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment