diff options
| author | littleblack111 <jerrylam110209@gmail.com> | 2023-06-14 20:40:56 +0800 |
|---|---|---|
| committer | littleblack111 <jerrylam110209@gmail.com> | 2023-06-14 20:40:56 +0800 |
| commit | bd7784d182c0c7609d419817b18462283e51062d (patch) | |
| tree | 767f82745b44503c29e2f52c69557029f6588055 /killport | |
| parent | 1ed1813d356b3289e60b2aadfcb997ef4e510efb (diff) | |
update
Diffstat (limited to 'killport')
| -rwxr-xr-x | killport | 14 |
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 |
