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?
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.