Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I kill this tomcat process in Terminal?

Using ps -ef | grep tomcat I found a tomcat server that is running. I tried kill -9 {id} but it returns "No such process." What am I doing wrong?

Here's an example:

Admins-MacBook-Pro:test-parent tom.maxwell$ ps -ef | grep tomcat
2043706342 39707 39695   0  3:40PM ttys000    0:00.00 grep tomcat
Admins-MacBook-Pro:test-parent tom.maxwell$ kill -9 39707
-bash: kill: (39707) - No such process
like image 517
Tom Maxwell Avatar asked Mar 05 '13 23:03

Tom Maxwell


4 Answers

There is no need to know Tomcat's pid (process ID) to kill it. You can use the following command to kill Tomcat:

pkill -9 -f tomcat
like image 63
Darshan Avatar answered Oct 15 '22 16:10

Darshan


ps -ef | grep tomcat | awk '{print $2}' | xargs kill -9

https://gist.github.com/nrshrivatsan/1d2ea4fcdcb9d1857076

Part 1

ps -ef | grep tomcat => Get all processes with tomcat grep

Part 2

Once we have process details, we pipe it into the part 2 of the script

awk '{print $2}' | xargs kill -9 => Get the second column [Process id] and kill them with -9 option

Hope this helps.

like image 35
suryakrupa Avatar answered Oct 15 '22 17:10

suryakrupa


Tomcat is not running. Your search is showing you the grep process, which is searching for tomcat. Of course, by the time you see that output, grep is no longer running, so the pid is no longer valid.

like image 20
Aurand Avatar answered Oct 15 '22 17:10

Aurand


just type the below command in terminal

ps -ef |grep 'catalina'

copy the value of process id then type the following command and paste process id

 kill -9 processid
like image 15
ASR Avatar answered Oct 15 '22 16:10

ASR