Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Bash script to kill the process by port

# lsof -i tcp:8080 | awk 'FNR == 2{print $2}' | xargs kill -9



 function killByPort {
        local port=$1
        echo "killing port ${port}"
        lsof -i tcp:${port} | awk 'FNR == 2{print $2}' | xargs kill -9
        echo "done . . . "
}


killByPort $1


## use : sh killByPort.sh {port}
# port -> 2020, 8000
Source by unix.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #Bash #script #kill #process #port
ADD COMMENT
Topic
Name
6+3 =