Linux supports the BSD style switches to the ps
command (without the leading - ... dash/hyphen). If one supplies the hypen then the GNU coreutils version of ps
(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 -o
option 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 the init
process. The normal init
under 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 init
does).
This question really should go on ServerFault