Linux - Clean up zombie processes

To kill zombie processes, you can follow these steps:

  1. Find the parent process ID (PPID) of the zombie process:

Run ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' command to find the PID of the zombie process and its parent process.

ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' 
  1. Kill the parent process of the zombie process:

If you determine that the zombie process is a child of a specific process, you can try to kill the parent process. Use the kill -9 <PPID> command to forcefully terminate the parent process of the zombie process.

  1. Restart the system:

In some cases, where the parent process of a zombie process cannot be killed for other reasons, you may need to reboot the system, which will clear all zombie processes.

In most cases, zombie processes are caused by programming errors and should be avoided by modifying the corresponding program code. If you find yourself dealing with zombie processes frequently, it's a good idea to find and fix the underlying issues that cause them to appear.

// 清理僵尸进程 
ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' | grep openvpn | grep -v 'grep' | awk '{print $2}' | xargs kill -9

Guess you like

Origin blog.csdn.net/xuezhangjun0121/article/details/135390441