How do I get the path of a process in Unix / Linux

后端 未结 11 588
无人共我
无人共我 2020-12-02 04:31

In Windows environment there is an API to obtain the path which is running a process. Is there something similar in Unix / Linux?

Or is there some other way to do th

11条回答
  •  情深已故
    2020-12-02 04:51

    Find the path to a process name

    #!/bin/bash
    # @author Lukas Gottschall
    PID=`ps aux | grep precessname | grep -v grep | awk '{ print $2 }'`
    PATH=`ls -ald --color=never /proc/$PID/exe | awk '{ print $10 }'`
    echo $PATH
    

提交回复
热议问题