引用
[mpsp@bj-app-170 ~]$ /usr/sbin/lsof -i tcp:1098 -n
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 11633 mpsp 33u IPv4 989025914 TCP 127.0.0.1:rmiactivation (LISTEN)
java 11633 mpsp 350w IPv4 1022001790 TCP 127.0.0.1:rmiactivation->127.0.0.1:44029 (ESTABLISHED)
java 11633 mpsp 454u IPv4 1021999581 TCP 127.0.0.1:rmiactivation->127.0.0.1:39408 (ESTABLISHED)
java 11633 mpsp 472r IPv4 1021999829 TCP 127.0.0.1:rmiactivation->127.0.0.1:45042 (ESTABLISHED)
可以看到1098端口被进程11633占用着,即jboss服务进程。
引用
# ps -ef|grep 11633
mpsp 11633 11604 6 Oct02 ? 22:37:29 /usr/jdk/bin/java -Dprogram.name=run.sh -server -Xms256m -Xmx1024m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/usr/mpsp/jbossa/lib/endorsed -classpath /usr/mpsp/jbossa/bin/run.jar:/usr/jdk/lib/tools.jar org.jboss.Main -c all -b 127.0.0.1
另外我们可以按照如下格式查看占用进程
引用
lsof -i TCP:port -n
lsof -i UDP:port -n
lsof -i :port -n