Linux work note 027 -- centos7.3 view the port number occupied by tomcat

Keywords: Tomcat Apache Java Unix

JAVA technology exchange QQ group: 170933152 

Take a look at the figure below. Execute two commands. First find the pid of tomcat, and then find the port according to the pid

 

It can be seen as follows:

1. Check the process number of tomcat first

ps -ef | grep tomcat*

The * sign is followed to view multiple tomcat, such as tomcat6 and tomcat7.

 

2. View port number according to process number

 

netstat -anop | grep 15161

 

You can see that port numbers 8865, 8866 and 8867 are occupied

 

3. In addition, you can also view the process number information through the port number

lsof -i: 8866

Last login: Sat Sep 15 02:36:46 2018 from 172.21.73.1
[root@sqb-v06 ~]# ps -ef|grep tomcat
root      9386     1  0 01:50 ?        00:00:17 /lib/jvm/jre/bin/java -Djava.util.logging.config.file=/opt/tomca/apache-tomcat-8.0.46/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Djava.endorsed.dirs=/opt/tomcat/apache-tomcat-8.0.46/endorsed -classpath /opt/tomcat/apache-tomcat-8.0.46/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.0.46/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat/apache-tomcat-8.0.46 -Dcatalina.home=/opt/tomcat/apache-tomcat-8.0.46 -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-8.0.46/temp org.apache.catalina.startup.Bootstrap start
root     11514 11460  0 03:25 pts/1    00:00:00 grep --color=auto tomcat
[root@sqb-v06 ~]# netstat -anop|grep 9386
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      9386/java            off (0.00/0/0)
tcp6       0      0 :::8009                 :::*                    LISTEN      9386/java            off (0.00/0/0)
tcp6       0      0 :::8088                 :::*                    LISTEN      9386/java            off (0.00/0/0)
unix  2      [ ]         STREAM     CONNECTED     34054    9386/java            
unix  2      [ ]         STREAM     CONNECTED     37227    9386/java            
[root@sqb-v06 ~]# 

 

Posted by desmortes on Fri, 03 Jan 2020 06:20:29 -0800