Linux 根據PID找到相應應用程序的運行目錄
阿新 • • 發佈:2018-09-02
12px pid tro 應用程序 exe ont span server 運行程序
1.找到運行程序的PID
# ps aux | grep redis root 1210 0.0 0.0 103336 900 pts/0 S+ 09:32 0:00 grep redis root 1782 0.1 0.7 143924 7704 ? Ssl Aug30 5:55 redis-server *:4705 # ps aux | grep redis root 1210 0.0 0.0 103336 900 pts/0 S+ 09:32 0:00 grep redis root 1782 0.1 0.7 143924 7704 ? Ssl Aug30 5:55 redis-server *:4705 #
不管用ps也好,top也罷,只要能夠找到運行程序的PID,例如,上面redis的pid為1782
2.找到程序的路徑
# ls -al /proc/1782/exe lrwxrwxrwx. 1 root root 0 8月 31 04:10 /proc/1782/exe -> /usr/local/bin/redis-server
根據PID則可以在/proc/PID/exe 找到程序所在的目錄
Linux 根據PID找到相應應用程序的運行目錄