Created
October 29, 2024 11:58
-
-
Save pavelglebov/e5e3f121b2b3f2ff565f6d95373a4db7 to your computer and use it in GitHub Desktop.
release_port {port} command for terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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