Linux下查看端口占用情况
用启动服务的账号登录,然后运行命令:
lsof -i:<端口号>
例如:
www.2cto.com
Linux代码
[root@SonarServer1 user0]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 19408 root 144u IPv6 183572842 0t0 TCP *:http (LISTEN)
www.2cto.com
也可使用命令:
netstat -apn|grep <端口号>
例如:
Linux代码
[root@SonarServer1 user0]# netstat -apn|grep 80
tcp 0 0 :::80 :::* LISTEN 19408/java
找到进程号以后,再使用以下命令查看详细信息:
ps -aux|grep <进程号>
Linux代码
[root@SonarServer1 user0]# ps -aux|grep 19408
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 19408 3.8 2.2 2520992 357368 ? Sl 10:29 0:27 java -Djava.awt.headless=true -XX:MaxPermSize=128m -Xms256m -Xmx512m -Djava.library.path=./lib -classpath ../../lib/servlet-api-2.5-20081211.jar:../../lib/jetty-util-6.1.25.jar:../../lib/activation-1.1.jar:../../lib/geronimo-spec-jta-1.0-M1.jar:../../lib/wrapper-3.2.3.jar:../../lib/commons-io-2.0.1.jar:../../lib/jetty-6.1.25.jar:../../lib/sonar-application-3.2.jar:../../lib/jetty-naming-6.1.25.jar:../../lib/jetty-plus-6.1.25.jar:../../:../../extensions/jdbc-driver/mysql/mysql-connector-java-5.1.18.jar:../../extensions/jdbc-driver/postgresql/postgresql-9.0-801.jdbc3.jar:../../extensions/jdbc-driver/mssql/jtds-1.2.4.jar -Dwrapper.key=n24m_l80HqD33MJi -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=19406 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp org.sonar.application.StartServer
root 19460 0.0 0.0 105476 948 pts/5 S+ 10:41 0:00 grep 19408