Skip to content

Instantly share code, notes, and snippets.

@thiagooak
Created December 13, 2013 12:11
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save thiagooak/7943393 to your computer and use it in GitHub Desktop.
Save thiagooak/7943393 to your computer and use it in GitHub Desktop.
kill ALL rabbitmq connections
rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" | "/bin/bash" }'
@EliasSMMX
Copy link

This helped a lot!! Thanks.

@AndreCimander
Copy link

Oh man, thanks for that, the perfect shim for our hanging celery workers 👍

@spmarco
Copy link

spmarco commented Mar 13, 2018

Save my life too. Thanks

@kyleian
Copy link

kyleian commented Apr 14, 2018

Thanks.

@olivertappin
Copy link

olivertappin commented Oct 14, 2019

This command also added the Listing connections ... line as:

rabbitmqctl close_connection "Listing" "manually closing idle connection"

I slightly changed it to this instead, which seems more resilient:

sudo rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name \
 | grep -vP 'Listing|pid' \
 | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" }' \
 | sudo sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment