linux-ps

Not only once i use the command to find zombie process, because of it’s so long i don’t mind to remember it. However, today i see all parameters of it and find that it is not hard enought as i ever thought.

command like this:

1
ps -eo stat,ppid,pid,cmd | grep -E '^Z'

each parameter above is important in use, i will tell you why.

  • -e: list all of processes, without it will not show full message
  • -o: used for format, without it cannot write needed field
  • stat: the main filed to recognize whether the process is zombie, the zombie process begin with Z
  • ppid: father process pid, if pid cannot end the process, need kill ppid
  • pid: process pid
  • cmd: this is used to see zombie process name

In a fact, if we only want to see whether there is a zombie process it can be much easier.

1
ps -eo stat | grep -E '^Z'

or use top command to see zombie processs number

then we need to kill zombie process we find, remember cannot use kill -9 pid to kill the process, because the status of process is end and it is just zombie.

1
2
3
4
kill -HUP pid

# or
kill -HUP ppid