-
-
Save antoniopresto/1244b50833bebc8018e3061829d79d62 to your computer and use it in GitHub Desktop.
Kill process
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
# kp 3000 node # kill if node is running on port 3000 | |
# kp 3000 # kill process running on port 3000 | |
PORT=$1; | |
MATCH=$2; | |
if [ -n "$MATCH" ]; then | |
kill -9 `lsof -i :$PORT | awk -v MATCH=$2 '$0 ~ MATCH{ print $2; }'` | |
exit; | |
fi; | |
kill -9 `lsof -i :$PORT | awk '{ if($2 != "PID"){ print $2; }}' ` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment