Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux command get tomcat process id by name

Linux command line:

When i execute the following command ps -ef |grep tomcat it shows me the following process

abcapp   28119     1  0 12:53 ?        00:00:19 /usr/java/jdk1.6.0_10//bin/java -Xmx256m -Dabc.log.file=/home/app/apps/rum/logs/dev.log -Dabc.config=dev -Dlog4j.configuration=file:///home/abcapp/env/abc_env/abc_env-1.2/config/log4j-webapp.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/home/abcapp/env/tomcat/tomcat-5.5-26-rum/conf/logging.properties -Djava.endorsed.dirs=/home/abcapp/env/tomcat/tomcat-5.5-26-rum/common/endorsed -classpath :/home/abcapp/env/tomcat/tomcat-5.5-26-rum/bin/bootstrap.jar:/home/abcapp/env/tomcat/tomcat-5.5-26-rum/bin/commons-logging-api.jar -Dcatalina.base=/home/abcapp/env/tomcat/tomcat-5.5-26-rum -Dcatalina.home=/home/abcapp/env/tomcat/tomcat-5.5-26-rum -Djava.io.tmpdir=/home/abcapp/env/tomcat/tomcat-5.5-26-rum/temp org.apache.catalina.startup.Bootstrap start

but when i issue following command it shows nothing

pgrep tomcat-5.5-26-rum OR pgrep "*-rum"

can some body help me how can i get tomcat process id by its name regex for "*-rum"

Thanks in advance.

like image 276
d-man Avatar asked Jan 03 '13 20:01

d-man


People also ask

How to find the process ID of tomcat in linux?

Netstat command to find the PID of process listening on a port. here you go, 25414 is the PID or process id of your tomcat server. Since tomcat is a Java web application it started with java command and that's why you see 25414/java. If you see this error, then just sudo as the user which is running the tomcat.

Where is PID of Java process in Linux?

Fig: 'ps' command displaying all Java processes running on Linux machine. The red color highlight in the above figure indicates the process IDs of all Java processes running on this EC2 instance. From here, you can get hold of your application's process ID.

Where is Tomcat service name in Linux?

A simple way to see if Tomcat is running is to check if there is a service listening on TCP port 8080 with the netstat command. This will, of course, only work if you are running Tomcat on the port you specify (its default port of 8080, for example) and not running any other service on that port.

Where is tomcat pid?

For one, the pid is contained in a file, either under the Tomcat directory, or somewhere under var, inspect the catalina.sh and/or setenv.sh scripts to find out exactly where.


1 Answers

pgrep only search for the process name without the full path (in your case only java) and without arguments.

Since tomcat-5.5-26-rum is part of the latter, i'd search the pid with

ps -ef | grep tomcat-5.5-26-rum | grep java | awk ' { print $2 } '

The double grep is useful to discard the grep pids itself

like image 96
Davide Berra Avatar answered Oct 04 '22 08:10

Davide Berra