Skip to content

Instantly share code, notes, and snippets.

@pavelglebov
Created October 29, 2024 11:58
Show Gist options
  • Save pavelglebov/e5e3f121b2b3f2ff565f6d95373a4db7 to your computer and use it in GitHub Desktop.
Save pavelglebov/e5e3f121b2b3f2ff565f6d95373a4db7 to your computer and use it in GitHub Desktop.
release_port {port} command for terminal
#!/bin/bash
# Check if port number is provided
if [ -z "$1" ]; then
echo "Usage: release_port <port>"
exit 1
fi
PORT=$1
# Find the process IDs using the specified port and kill them
lsof -i :$PORT | grep LISTEN | awk '{print $2}' | xargs -r kill -9
echo "Released port $PORT."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment