0

I want to kill tomcat process and hence used command -

ps -ef | grep 'tomcat'

and it returns following big output and there I can see 3 pids -

oracle    76220 218600  3 May16 pts/2    00:40:14 /usr/bin/java -Djava.util.logging.config.file=/home/oracle/apache-tomcat-8.5.11/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms1024m -Xmx10240m -XX:MaxMetaspaceSize=512m -Djava.awt.headless=true -DcoreJMX=true -DqueryJMX=true -javaagent:/home/oracle/Jacoco/jacoco-0.7.5.201505241946/lib/jacocoagent.jar=destfile=/home/oracle/Jacoco/jacoco141.exec,append=false,includes=com.eqtechnologic.* -verbose:gc -Xloggc:/home/oracle/apache-tomcat-8.5.11/logs/gcLogs.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /home/oracle/apache-tomcat-8.5.11/bin/bootstrap.jar:/home/oracle/apache-tomcat-8.5.11/bin/tomcat-juli.jar -Dcatalina.base=/home/oracle/apache-tomcat-8.5.11 -Dcatalina.home=/home/oracle/apache-tomcat-8.5.11 -Djava.io.tmpdir=/home/oracle/apache-tomcat-8.5.11/temp org.apache.catalina.startup.Bootstrap start
oracle   138680 219157  0 15:46 pts/4    00:00:00 grep --color=auto tomcat
oracle   187823 161915  1 May16 pts/1    00:29:01 //bin/java -Djava.util.logging.config.file=/home/oracle/apache-tomcat-8.5.11/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms1024m -Xmx10240m -XX:MaxMetaspaceSize=512m -Djava.awt.headless=true -DcoreJMX=true -DqueryJMX=true -javaagent:/home/oracle/Jacoco/jacoco-0.7.5.201505241946/lib/jacocoagent.jar=destfile=/home/oracle/Jacoco/jacoco141.exec,append=false,includes=com.eqtechnologic.* -verbose:gc -Xloggc:/home/oracle/apache-tomcat-8.5.11/logs/gcLogs.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /home/oracle/apache-tomcat-8.5.11/bin/bootstrap.jar:/home/oracle/apache-tomcat-8.5.11/bin/tomcat-juli.jar -Dcatalina.base=/home/oracle/apache-tomcat-8.5.11 -Dcatalina.home=/home/oracle/apache-tomcat-8.5.11 -Djava.io.tmpdir=/home/oracle/apache-tomcat-8.5.11/temp org.apache.catalina.startup.Bootstrap start

But I am confused which one is pid of tomcat. Can someone please help me to understand how to read this output which will help me to get pid of tomcat?

If I guessed correctly, is 138680 pid of tomcat?

2
  • No, that's the PID of your grep command. Doesn't Tomcat have a special shutdown.sh script? – Kusalananda May 17 '20 at 7:21
  • Actually I have Jacoco (Java code coverage tool) integrated and it generates report in jacoco.exec file when application is turned down. But when I run shutdown.sh, it does not generate report hence it's not helping. If I use CTRL+C, for running application(which is run using catalina..sh run). To invoke behaviour like CTRL+C through shell script, I'm trying to use kill -SIGINT processPIDHere hence want to get pid. – Alpha May 17 '20 at 10:48
0

Like Kusalananda said in the comment, Tomcat has a shutdown.sh script in the bin folder. Anyway, if for some reason you want to kill it with the kill command, there is the pidof command that gives you the pid of a running program.

4
  • 1
    Also pkill, which would be more direct, but their issue seems to be figuring out how to select the right process. Using the shutdown.sh script would be the best alternative as that script probably shots down the service in a more orderly manner. – Kusalananda May 17 '20 at 9:04
  • pkill -9 -f tomcat is also not helping me to achieve what I mentioned in comment to question. – Alpha May 17 '20 at 10:54
  • @TDHM Did you try with the INT signal in place of the KILL signal? – Kusalananda May 17 '20 at 11:15
  • I am getting INT command not found. I'm newbie to linux environment. Can you please help with exact command? – Alpha May 17 '20 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.