We have discussed kill before.
Start an application you don’t care about, say an instance of a text editor like gedit. Open a terminal and run top with the -b (for batch) option, and pipe it through grep with a phrase that should isolate the process (like “gedit”). Like this:
greg~$ top -b | grep "gedit"
7360 greg 20 0 32724 18m 10m S 0 0.6 0:00.64 gedit
That line starting with 7360 will keep printing out until you hit Ctrl-C or some other brutish command to stop the top process. But now you know that the process number is 7360 (or whatever it is on your machine, most assuredly different). So you can kill it using the kill command. The whole thing looks like this:
greg~$ top -b | grep "gedit"
7360 greg 20 0 32724 18m 10m S 0 0.6 0:00.64 gedit
7360 greg 20 0 32724 18m 10m S 0 0.6 0:00.64 gedit
greg~$ kill 7360
greg~$ top -b | grep "gedit"
greg~$
Notice that the second time around, there was no output, because the process was dead.
Fine. But what if you are not sure if you want to kill the process, but you do want to know that it is there, in your sights, in case you want to do it it? In other words, you have a process ID but are not sure what the status of the process is.
Kill with the -0 flag will return a 0 for a process that is running (zero is the normal returned value for normal or successful things). But it won’t kill the process. Think of -0 (and that is a zero) as the “don’t really kill it” flag.
This may seem a bit esoteric, but when you need to know how to do it, you will appreciate the tip. Just come to this blog and search for the string “kill the process gently” and you’ll be good to go.
I totally stole this from here.




