How do I kill this tomcat process in Terminal? How do I kill this tomcat process in Terminal? unix unix

How do I kill this tomcat process in Terminal?


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


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.


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.