Determine the process pid listening on a certain port

Cyclone picture Cyclone · Mar 25, 2012 · Viewed 216.2k times · Source

As the title says, I'm running multiple game servers, and every of them has the same name but different PID and the port number. I would like to match the PID of the server which is listening on certain port, and then I would like to kill this process. I need that in order to complete my bash script.

Is that even possible? Because it didn't find yet any solutions on the web.

Answer

Laurynas picture Laurynas · Dec 29, 2012

Short version which you can pass to kill command:

lsof -i:80 -t