Skip to content

Instantly share code, notes, and snippets.

@hartfordfive
Last active October 30, 2023 04:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save hartfordfive/5928e7bca7c6239e4e1036346d326953 to your computer and use it in GitHub Desktop.
Save hartfordfive/5928e7bca7c6239e4e1036346d326953 to your computer and use it in GitHub Desktop.
Script to delete all kafka topics on a given cluster
#!/bin/bash
TOPICS=$(kafka-topics --zookeeper [ZK_IP]:2181/kafka --list )
for T in $TOPICS
do
if [ "$T" != "__consumer_offsets" ]; then
kafka-topics --zookeeper [ZK_IP]:2181/kafka --delete --topic $T
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment