shell script to kill the process listening on port 3000?

Jonathan picture Jonathan · Feb 6, 2012 · Viewed 76.8k times · Source

I want to define a bash alias named kill3000 to automate the following task:

$ lsof -i:3000

COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
ruby    13402 zero    4u  IPv4 2847851      0t0  TCP *:3000 (LISTEN)

$ kill -9 13402

Answer

SamB picture SamB · Feb 7, 2012
alias kill3000="fuser -k -n tcp 3000"