Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine the process pid listening on a certain port

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.

like image 616
Cyclone Avatar asked Mar 24 '12 23:03

Cyclone


People also ask

How do I find the PID of a process in Terminal?

A process is nothing but running instance of a program and each process has a unique PID on a Unix-like system. The easiest way to find out if process is running is run ps aux command and grep process name. If you got output along with process name/pid, your process is running.

How do I find out what application is using a TCP port?

How do I find out what application is using a TCP port? You can use Netstat -b -a -o. This tool provides a list of all open ports and their associated processes. The -o shows the process id, which you can look up in your task manager or processes tab.


1 Answers

Short version which you can pass to kill command:

lsof -i:80 -t 
like image 157
Laurynas Avatar answered Sep 28 '22 07:09

Laurynas