linux 查看进程号所在的启动目录
方法1:pwdx pid号(pid为你想查看的进程的pid)
例:
[root@vm-kvm18118-app ~]# ps -ef|grep java
root 42319 1 0 Jun15 ? 00:02:26 java -jar csgl-server-1.1.0.jar
root 47104 1 7 Jun04 ? 22:07:22 java -Xmx8192m -XX:-UseGCOverheadLimit -Djava.ext.dirs=../libs:/opt/app/env/jdk/jre/lib/ext TestinStack.UnityPlatform.ApplicationBoot -
root 59323 58874 0 10:16 pts/1 00:00:00 grep --color=auto java
[root@vm-kvm18118-app ~]# pwdx 42319
42319: /home/test/csgl_test
方法2:ls -l /proc/pid号
例:
[root@vm-kvm18118-app ~]# ps -ef|grep java
root 42319 1 0 Jun15 ? 00:02:26 java -jar csgl-server-1.1.0.jar
root 47104 1 7 Jun04 ? 22:07:59 java -Xmx8192m -XX:-UseGCOverheadLimit -Djava.ext.dirs=../libs:/opt/app/env/jdk/jre/lib/ext TestinStack.UnityPlatform.ApplicationBoot -
root 59522 58874 0 10:18 pts/1 00:00:00 grep --color=auto java
[root@vm-kvm18118-app ~]# ls -l /proc/42319
total 0
dr-xr-xr-x 2 root root 0 Jun 16 10:18 attr
-rw-r--r-- 1 root root 0 Jun 16 10:18 autogroup
-r-------- 1 root root 0 Jun 16 10:18 auxv
-r--r--r-- 1 root root 0 Jun 16 10:18 cgroup
--w------- 1 root root 0 Jun 16 10:18 clear_refs
-r--r--r-- 1 root root 0 Jun 16 10:10 cmdline
-rw-r--r-- 1 root root 0 Jun 16 10:18 comm
-rw-r--r-- 1 root root 0 Jun 16 10:18 coredump_filter
-r--r--r-- 1 root root 0 Jun 16 10:18 cpuset
lrwxrwxrwx 1 root root 0 Jun 16 10:11 cwd -> /home/test/csgl_test
-r-------- 1 root root 0 Jun 16 10:18 environ
lrwxrwxrwx 1 root root 0 Jun 15 14:41 exe -> /opt/app/env/jdk/jre/bin/java
......
结果中,exe链接对应的就是可执行文件的全路经,cwd就是目录