1:根据端口号查找对应的进程 id
(1): [root@192 local]# lsof -i:6122
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 22775 root 42u IPv6 7350952 0t0 TCP *:bex-webadmin (LISTEN)
[root@192 local]#
(2): [root@192 local]# netstat -apn|grep 6122
tcp 0 0 :::6122 :::* LISTEN 22775/java
[root@192 local]#
得到进程 id = 22775
2:根据进程 id 查找程序目录
[root@192 local]# cat /proc/22775/environ
HOSTNAME=192.168.45.35TERM=xterm-newSHELL=/bin/bashHISTSIZE=1000SSH_CLIENT=192.168.41.121 51588 22QTDIR=/usr/lib64/qt-3.3QTINC=/usr/lib64/qt-3.3/includeSSH_TTY=/dev/pts/0USER=rootLS_COLORS=MAVEN_HOME=/opt/maven/apache-maven-3.2.2MAIL=/var/spool/mail/rootPATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/maven/apache-maven-3.2.2/bin/:/root/bin **PWD=/usr/local/src/tomcat7x/bin** KDE_IS_PRELINKED=1LANG=zh_CN.UTF-8KDEDIRS=/usrSSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpassHISTCONTROL=ignoredupsSHLVL=2HOME=/rootLOGNAME=rootQTLIB=/usr/lib64/qt-3.3/libCVS_RSH=sshSSH_CONNECTION=192.168.41.121 51588 192.168.45.35 22LESSOPEN=|/usr/bin/lesspipe.sh %sHISTTIMEFORMAT=%F %T root G_BROKEN_FILENAMES=1_=/opt/jdk1.7.0_15/bin/java[root@192 local]#
得到目录地址 PWD=/usr/local/src/tomcat7x/bin
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于