Servers - General
1847822 Members
4030 Online
104021 Solutions
New Discussion

Re: How to find the Process path

 
satha
Occasional Contributor

How to find the Process path

I have a process running and i need to find out the process path

sxxxxxc: home/sxxxxai $ ps -ef |grep -i jmx
sxxxxxai 12571 4873 1 19:50:42 pts/0 0:00 grep -i jmx

By above i can see that JMX Process id is 12571 , how to find out the location of the file

Same for below 

sxxxxc:home/sxxxxi $ ps -ef |grep -i activemq
sxxxxxi 13090 4873 0 19:56:50 pts/0 0:00 grep -i activemq

 

I have tried below  commands but of no use

pwdx 13090

sudo ls -l /proc/13090/exe

readlink -f /proc/<13090>/exe

lsof -p 13090 | grep cwd

 

 

 

2 REPLIES 2
georgek_1
HPE Pro

Re: How to find the Process path

Hello Satha,

The process id "12571" you have mentioned/seeing, is the PID of the "ps" command ran with grepping for jmx and there is no process with name "jmx" included in server .
sxxxxxc: home/sxxxxai $ ps -ef |grep -i jmx
sxxxxxai 12571 4873 1 19:50:42 pts/0 0:00 grep -i jmx

Here, it says there is only one entry on ps table with "jmx" included is the "grep -i jmx" which you executed .
The process ID would exit once you get the prompt back with the output .

Same is the case of the other command you ran .
sxxxxc:home/sxxxxi $ ps -ef |grep -i activemq
sxxxxxi 13090 4873 0 19:56:50 pts/0 0:00 grep -i activemq

Following would the output when there is an actual process running , here is an example of sshd .
# ps -ef | grep -i sshd
    root  9881     1  0  Feb  2  ?         0:00 /opt/ssh/sbin/sshd
    root 10988  9881  0 20:37:58 ?         0:00 sshd: root@pts/1
    root 27884 24409  0 22:15:40 pts/0     0:00 grep -i sshd

Here , PID 27884 is for the grep command executed .
PID 10988 is the sshd child process and PID 9881 is the actual SSHD process running in server , where you could also see the path of the binary .

I work for HPE/ I am an HPE Employee (HPE Community)



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
sarafoster
Member

Re: How to find the Process path

To find the location of the process file, you can try using the ls command with the process ID. Here's how you can do it:

For the JMX process with ID 12571:

bashCopy code 
ls -l /proc/12571/exe

This should give you the full path to the process file.

For the ActiveMQ process with ID 13090:

bashCopy code
ls -l /proc/13090/exe

This should also give you the full path to the process file.

Note that you need to have sufficient permissions to access the process file. If you're not running these commands as the same user that started the process, you may need to run them with sudo.

Also, if the process has already terminated, the /proc directory may no longer contain information about the process, in which case you won't be able to find the process file using this method.