DD. Asked: 2012-07-10 08:34:48 +0800 CST2012-07-10 08:34:48 +0800 CST 2012-07-10 08:34:48 +0800 CST Kill process by command name 772 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). linux kill grep 4 Answers Voted Best Answer Sirch 2012-07-10T08:36:52+08:002012-07-10T08:36:52+08:00 Simples, use pkill pgrep, pkill - look up or signal processes based on name and other attributes James Sneeringer 2012-07-10T08:48:33+08:002012-07-10T08:48:33+08:00 One way is with killall: killall - kill processes by name blacksoul 2012-07-10T09:26:48+08:002012-07-10T09:26:48+08:00 You can do it with killall NAME. Also, you can use the option -e,--exact require exact match for very long names tacotuesday 2012-07-10T09:43:09+08:002012-07-10T09:43:09+08:00 If you want a quick script that will kill it in one line, try this: kill `ps aux | awk '$1 ~ "java" {print $2}'` Where "java" is in quotes, make sure you change it to whatever name Java is running under. You can check that by running ps aux If it won't die, you can use kill -9 instead, which ensures execution. kill -9 `ps aux | awk '$1 ~ "java" {print $2}'`
Simples, use
pkill
pgrep, pkill - look up or signal processes based on name and other attributes
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
ps aux
If it won't die, you can use
kill -9
instead, which ensures execution.