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.
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? 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.
Short version which you can pass to kill command:
lsof -i:80 -t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With