I have 2 tomcat's running, how do I get the pid if both have similar names?
ps -ef | grep java
root 12952 1 0 10:01 pts/0 00:00:03 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/usr/local/realbid/tomcat-realbid-ws/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/realbid/tomcat-realbid-ws/endorsed -classpath /usr/local/realbid/tomcat-realbid-ws/bin/bootstrap.jar -Dcatalina.base=/usr/local/realbid/tomcat-realbid-ws -Dcatalina.home=/usr/local/realbid/tomcat-realbid-ws -Djava.io.tmpdir=/usr/local/realbid/tomcat-realbid-ws/temp org.apache.catalina.startup.Bootstrap start
root 12995 1 0 10:02 pts/0 00:00:03 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/usr/local/realbid/tomcat-realbid/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/realbid/tomcat-realbid/endorsed -classpath /usr/local/realbid/tomcat-realbid/bin/bootstrap.jar -Dcatalina.base=/usr/local/realbid/tomcat-realbid -Dcatalina.home=/usr/local/realbid/tomcat-realbid -Djava.io.tmpdir=/usr/local/realbid/tomcat-realbid/temp org.apache.catalina.startup.Bootstrap start
root 13317 12252 0 10:12 pts/0 00:00:00 grep java
If I use basic grep I get both the pid(s)
echo `ps aux | grep 'tomcat-realbid' | grep -v grep | awk '{ print $2 }'`
12952 12995
Is there a way to get only the pid of tomcat-realbid
?