Last active
December 12, 2015 05:28
-
-
Save snow-swallow/4721669 to your computer and use it in GitHub Desktop.
It's a shell for killing process by your port in osx.
1) sudo mv killps.sh /usr/local/bin ## enter your local environment.
2) chmod +x killps.shell
3) killps 9001 ## enter the process port you wanna kill.
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/sh | |
lsof -n -i4TCP:$1 | grep LISTEN | |
pid=`lsof -n -i4TCP:$1 | grep LISTEN | awk '{print $2}'` | |
## when it is ubuntu, just replace '4TCP' to '6TCP' in line3. | |
if [ $pid ] | |
then | |
kill -9 $pid | |
echo "[`date "+%Y-%m-%d %H:%M:%S"`] Process kill successfull!" | |
else | |
echo "[`date "+%Y-%m-%d %H:%M:%S"`] No process exists on port $1." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment