server01:/# ps -ax | grep java
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
7342 pts/3 Z 0:00 [java] <defunct>
7404 pts/3 S+ 0:00 grep java
server01:/# kill 7342
server01:/# ps -ax | grep java
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
7342 pts/3 Z 0:00 [java] <defunct>
7406 pts/3 S+ 0:00 grep java
server01:/#
In the above I am using ps command to know the pid of the java process which is 7342 in the above case.
Then I killed that process using kill command.
But that is not killed because again ps command shows java process with pid 7342.
Should I use some else command to kill the process and Why kill is not able to kill the process
Thanx
Linux supports the BSD style switches to the
pscommand (without the leading – … dash/hyphen). If one supplies the hypen then the GNU coreutils version ofps(the one which is standard on mainstream Linux distributions) will attempt to interpret the switches as SysV compatible. This is the source of your error.I’d recommend using the BSD form of the switches and look up the
-ooption to specify an output format consisting ONLY of the PID of the matching processes.Also you’re attempting to kill a zombie. As you’ve discovered that’s a futile effort. A zombie is a placeholder in the process able for a process which is already dead. It remains in the process table until its parent process “reaps” its exit code. If the parent never does a
wait()system call then the entry will stay there until after the parent is killed, at which point the zombie (and any other orphaned processes) will be inherited by theinitprocess. The normalinitunder Linux (or any other form of UNIX) periodically reaps all dead processes (zombies).Conceptually every process that exits on a UNIX/Linux system spends a small amount of time as a “zombie” … that is there should always be a period of time between the process’ termination and the time when some other process reads its exit value (even if only to discard it, as
initdoes).This question really should go on ServerFault