summaryrefslogtreecommitdiff
path: root/killport
diff options
context:
space:
mode:
Diffstat (limited to 'killport')
-rwxr-xr-xkillport14
1 files changed, 14 insertions, 0 deletions
diff --git a/killport b/killport
new file mode 100755
index 0000000..d45264b
--- /dev/null
+++ b/killport
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+
+if [ ! $1 ]; then
+ echo "Please give a port"
+ exit
+elif [ $2 ]; then
+ echo "Only 1 argument(port) need to be given"
+ exit
+elif $(kill $(lsof -t -i :$1) 2> /dev/null); then
+ echo "Killed $(ps -p $(lsof -t -i :$1) -o comm=) with SIGTERM"
+else
+ echo "No process in port"
+fi