How to kill defunct zombie process


On Unix and Linux operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table.

Oracle  Solaris:

  • Identify the process  IDs  of the defunct  process

#ps  -ecl|grep “Z”
  • kill the defunct  process  with  “preap” command

#preap  <PID>
  • If there are multiple zombi processes then use this command to kill all processes at once.

#ps -A | grep defunct | awk ‘{print $1}’ | xargs preap

Linux:

  • Identify the process  IDs  of the defunct  process

#ps -A -ostat,ppid | grep -e ‘[zZ]’ 
  • kill the defunct  process  with  “kill” command

#kill  -9 <PID>
  • If there are  multiple  zombi processes  then use  this command to kill  all  process at  once.

#for  i  in $(ps -A -ostat,ppid | grep -e ‘[zZ]’| awk ‘{ print $2 }’); do kill  -9  $i; done

HP-UX:

  • Identify process  IDs of the defunct  process

#ps -el | grep ‘Z’
  • kill defunct process with  “kill” command. But first, check zombi  process  parent ID

#ptree <PID>
#kill -9 <PID>   //some  cases  this  action doesn’t  work  . You need  to kill parent  ID. But  be carefull  when you  kill parent  ID. 
  • If there are multiple zombi processes then use this command to kill all processes at once.

#for  i  in $(ps -el | grep ‘Z’|grep  -v PID|awk  ‘{print $4}’); do kill  -9  $i; done   // be carefull before  run  command.

 

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me