Last active
July 31, 2019 21:03
-
-
Save nikolareljin/aae6d93e144cb28b7d6cbe5b8abef8d1 to your computer and use it in GitHub Desktop.
Kill all apps running on certain port
This file contains hidden or 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
#!/usr/bin/env bash | |
# ------------------------------------------------- | |
# Kills all apps running on given port | |
# Use: | |
# kill_apps_on_port.sh <port> | |
# ------------------------------------------------- | |
PORT_NUMBER=$1 | |
echo "Kill all applications running on port ${PORT_NUMBER}" | |
lsof -i tcp:${PORT_NUMBER} | awk 'NR!=1 {print $2}' | sudo xargs kill | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment