1

Tried with some examples like ps and ps -ef,after killing a process by using kill-9 PID in Linux,how to verify weather the process is killed or not?

Joe
  • 11
  • 2
  • Could see the list of process with top command and kill with kill -9 PID, now how to verify it weather the process is killed or not? – Joe Sep 11 '15 at 16:31
  • 1
    It is common for people to have only heard of SIGKILL (`-9`) to terminate a process. The proper way is to ask it nicely to close itself first using `kill -TERM pid` and if it doesn't respond to that after a little, then [you can bring out the](http://stackoverflow.com/questions/4042201/how-does-sigint-relate-to-the-other-termination-signals) `kill -9`. It's like the difference between asking your guest to leave and shooting him dead with no warning. – msw Sep 11 '15 at 17:14

2 Answers2

0

Just run ps aux stat,pid again, and you will see the process with this pid is either a zombie ('Z' in the first column) or dead.

Edit: Thanks, Mark B, for pointing me about zombies.

0

Ater the kill, check the PID of the process:

$ pidof PROCESS

You should see no output if the process is gone.

Another similar way:

$ ps aux | grep PROCESS

Notes:

  • You can kill your own process, but only root user can kill system process or another user process.
  • After you KILL the process you can get a zombie, you can still see it in the process list but with process STATE Z (wich means Zombie). Zombies cant be killed, they are already dead, so to "kill" zombies you need to kill the zombie's parents. That said, in general you don’t need to get rid of zombie processes unless you have a large amount of them.
JosEduSol
  • 5,268
  • 3
  • 23
  • 31