The first way: we know the port number using the following method
Sometimes we know a service port is running in the background and want to shut it down. For example, TOMCAT is port 8080, running in the background. How do I turn it off?
View the PID of this process by port
Netstat LNP | grep 8080 # 8080, please change to your apache to portCopy the code
View details about a process
Ps 1777 #1777 is the PID obtained in the previous stepCopy the code
Kill the process
For example, kill -9 [PID] #-9 forces the process to stop immediatelyCopy the code
Second: we know the service name such as query tomcat
View process details based on pid
ps -ef|grep redis root 7474 1 0 14:58 ? 00:00:01 /usr/local/redis/redis-4.0.11/ SRC /redis-server 127.0.0.1:6379 root 7794 2175 0 15:30 PTS /0 00:00:00 grep --color=auto redis 7474Copy the code
How to view port through PID
netstat -antup |grep 2711
Copy the code
Jar type projects are executed in the background
Nohup Java -jar xx.jar >temp.text & //nohup means to run the command without hanging up, and the program will still run when the account is logged out or the terminal is closed. By default, all output of the job is redirected to the nohup.out file // unless an output file is specified otherwise. // This method will input the log file to the file you specify, otherwise it will be created automaticallyCopy the code
Window to kill the process
netstat -ano | findstr 9999
taskkill /f /pid 12612
Copy the code
Under the window since the rev
%USERPROFILE% AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartupCopy the code