Search code examples
centos

Full path to running script?


LInux CentOS 7

To show is running my bash script I use this in terminal:

ps -ef | grep myScript.sh

And here result:

root      6886 31386  0 10:04 pts/0    00:00:00 grep --color=auto myScript.sh

Nice. But I also need to show full path to myScript.sh.

Smt like this:

 root      6886 31386  0 10:04 pts/0    00:00:00 grep --color=auto /etc/application/scripts/myScript.sh

Is it possible?


Solution

  • Your script doesn't seem to be running here, the process displayed as output is grep and not your script.

    Let's try to explain with an example:

    I use grep to find if the process script.sh is running, I use the following command :

    ps -ef | grep script.sh
    

    If the process is running you will have the following result :

    • The process (script.sh)
    • The grep process searching for script.sh

    Like this :

    root      842310  842214  0 08:14 pts/2    00:00:00 /bin/bash ./script.sh
    root      842338  842299  0 08:14 pts/4    00:00:00 grep --color=auto script.sh
    

    The process with PID 842310 is my running script.

    So make sure your script is running ;)

    For the path I don't know if you can get it. I have tried several methods but have not succeeded.