1、
Linux下通过进程名查询占用的端口
1、首先根据名称用ps命令查看进程ID:
[deployer@dev82 act_data_imp]$ ps -ef|grep data_imp deployer 11194 1 0 1月30 ? 00:55:03 java -jar act_data_imp-0.0.1-SNAPSHOT.jar deployer 300701 913811 0 16:33 pts/11 00:00:00 grep --color=auto data_imp
10997为进程ID
后面是启动路径和对应的进程名
1.1、对于在Java虚拟机中运行的进程,比如tomcat的守护进程,可以直接用jsp命令查看:
$ jps -l|grep data_imp
11194 act_data_imp-0.0.1-SNAPSHOT.jar
2、查到进程ID之后,使用netstat命令查看其占用的端口:
[deployer@dev82 act_data_imp]$ netstat -anp | grep 11194 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 0 0 :::8080 :::* LISTEN 11194/java tcp6 0 0 10.124.142.82:17370 10.124.0.42:1521 ESTABLISHED 11194/java tcp6 0 0 10.124.142.82:18892 10.124.142.47:2181 ESTABLISHED 11194/java unix 2 [ ] STREAM CONNECTED 1183389399 11194/java unix 2 [ ] STREAM CONNECTED 1183397092 11194/java