Skip to content

Instantly share code, notes, and snippets.

@portlandhodl
Created May 31, 2025 18:58
Show Gist options
  • Save portlandhodl/c198cb591085b34ff0f599b29878fb95 to your computer and use it in GitHub Desktop.
Save portlandhodl/c198cb591085b34ff0f599b29878fb95 to your computer and use it in GitHub Desktop.
Unix cron script to automatically disconnect Bitcoin Knots peers.
#!/bin/bash
# Get peer info and disconnect any peer with "knots" in the subver field
bitcoin-cli getpeerinfo | jq -r '.[] | select(.subver | ascii_downcase | contains("knots")) | .id' | while read peer_id; do
if [ ! -z "$peer_id" ]; then
echo "Disconnecting peer ID $peer_id with knots client"
bitcoin-cli disconnectnode "" "$peer_id"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment