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?
To kill a process by name I use the following
ps aux | grep "search-term" | grep -v grep | tr -s " " | cut -d " " -f 2 | xargs kill -9
The tr -s " " | cut -d " " -f 2
is same as awk '{print $2}'
. tr
supressess the tab spaces into single space and cut
is provided with
as the delimiter and the second column is requested. The second column in the ps aux
output is the process id.