linux 查看进程占用端口
2019-09-26 本文已影响0人
anyly
查看某些应用占用端口,排查某些端口被占用问题
1.先查看进程id
比如查看java进程id 现在是14981
root 14981 1 1 Aug15 ? 14:11:39 /usr/java/jdk1.8.0_144/jre/bin/java -Djava.util.logging.config.file=/usr/java/apache-tomcat-7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/usr/java/apache-tomcat-7/endorsed -classpath /usr/java/apache-tomcat-7/bin/bootstrap.jar:/usr/java/apache-tomcat-7/bin/tomcat-juli.jar -Dcatalina.base=/usr/java/apache-tomcat-7 -Dcatalina.home=/usr/java/apache-tomcat-7 -Djava.io.tmpdir=/usr/java/apache-tomcat-7/temp org.apache.catalina.startup.Bootstrap start
root 25946 25919 0 16:20 pts/0 00:00:00 grep --color=auto java
2.执行命令 netstat -anp | grep 14981
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 14981/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14981/java
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 14981/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 14981/java
上面为该进程占用的port