Check the port number, check the process number, kill the process

lsof -i: port number Query the process occupying the port number (can only be executed with root privileges)

netstat -apn | grep port number to  query the process occupying the port number

ps -ef|grep PID query process information

kill PID kill process

 

The safest way to kill a process is to simply use the kill command, with no modifiers and no flags.

  First determine the PID of the process you want to kill using the ps -ef command, then enter the following command:
 
# kill -pid
 
NOTE: The standard kill command usually does the trick. Terminate the process in question and release the process' resources to the system. However, if a process starts a child process, and only kills the parent process, the child process is still running and thus still consuming resources. To prevent these so called "zombie processes", make sure to kill all of its child processes before killing the parent process.
 
Determine the PID or PPID of the process to kill
 
# ps -ef | grep httpd
 
End the process gracefully
 
# kill -l PID
 
The -l option tells the kill command to end the process as if the user who started the process was logged out. When this option is used, the kill command also attempts to kill any child processes left behind. But this command doesn't always work -- it might still be necessary to kill the child process manually first, and then kill the parent process.
 
TERM signal
 
Send a TERM signal to the parent process, trying to kill it and its children.
 
# kill -TERM PPID
 
killall command
 
The killall command kills all processes within the same process group. It allows to specify the name of the process to be terminated instead of the PID.
 
# killall httpd
 
Stop and restart processes
 
Sometimes you just want to simply stop and restart the process. as follows:
 
# kill -HUP PID
 
This command causes Linux's graceful execution process to shut down and then restart immediately. This command is very convenient when configuring the application, and can be executed when the process needs to be restarted after modifying the configuration file.
 
lore kill -9 PID
 
Agree kill -s SIGKILL
 
This powerful and dangerous command forces the process to terminate abruptly while it is running, and the process cannot clean itself up after it ends. The harm is that the system resources cannot be released normally, which is generally not recommended unless other methods are ineffective.
 
当使用此命令时,一定要通过ps -ef确认没有剩下任何僵尸进程。只能通过终止父进程来消除僵尸进程。如果僵尸进程被init收养,问题就比较严重了。杀死init进程意味着关闭系统。
 
如果系统中有僵尸进程,并且其父进程是init,而且僵尸进程占用了大量的系统资源,那么就需要在某个时候重启机器以清除进程表了。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327032037&siteId=291194637