Table of contents
Close process based on port number
Close process based on port number
Linux
Close process based on port number
Step 1: To query the process PID based on the port number, you can use the following command
netstat -anp | grep 8088(以8088端口号为例)
Step 2: Use the kill command to close the process. You can use the following command
kill -9 20950(以PID为20950为例)
Test effect: (Note: You must switch root permissions to use this command, otherwise the PID and service name will not appear)
Close Java service process
Step 1: Use the ps command to query the service process PID. You can use the following command
ps -ef | grep java(以java服务为例)
Step 2: Use the kill command to close the process. You can use the following command
kill -9 20950(以PID为20950为例)
Test results:
Windows
Close process based on port number
Step 1: Open the cmd window to query the PID based on the port number. You can use the following command
netstat -ano | findstr 9998(以9998端口号为例)
Step 2: Check the corresponding process according to the PID to ensure that the process is the service we want to shut down. You can use the following command
tasklist | findstr 2784(以PID为2784为例)
Step 3: Close the process based on PID, you can use the following command
taskkill /pid 2784 /f(以PID为2784为例)
Test results: