I would like to kill a java process based on the command name... Whats the best way to do it?
(i.e. when you do ps -f the name in the CMD column).
|
Simples, use
|
|||||||||
|
|
One way is with killall:
|
|||||||||
|
|
You can do it with killall NAME. Also, you can use the option
|
|||
|
|
|
If you want a quick script that will kill it in one line, try this:
Where "java" is in quotes, make sure you change it to whatever name Java is running under. You can check that by running If it won't die, you can use
|
|||||||
|
killall) by mistake. So if you plan to do that through a script I would recommend to try and get the PID from the java process. Especially if you developed the code just write the PID assigned to the process in one file, which you can use later on as an reference to terminate it. – golja Jul 11 '12 at 1:46