Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I executed the command to give the pid of my processes running, it gave me like this -

user@machineA:/$ ps -eo pid,command | grep exhibitor | grep java | grep -v grep
 1615 java -jar ./exhibitor-1.2.3/lib/exhibitor-1.2.3-jar-with-dependencies.jar --fsconfigdir /opt/exhibitor/conf --hostname machineA

Now I saw this path in the above output -

./exhibitor-1.2.3/lib/exhibitor-1.2.3-jar-with-dependencies.jar

Now I am trying to understand where this folder is ./exhibitor-1.2.3/ as I am not able to find out. Does this folder on the same ubuntu machine? Is there any way to find out that directory where it is?

I am running Ubuntu 12.04

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

The file name is relative to the current directory at the time the Java process tried to access it. There's no sure way to determine that. You can look at the process's current directory:

ls -l /proc/1615/cwd

If the process still has the file open, you'll be able to easily find out where it is.

ls -l /proc/1615/fd

If you can't find the file this way because the program changed its current directory, you can try checking the parent process's current directory, if the parent process is still alive. Use ps l 1615 to see the parent process's PID (PPID), then look at the parent process's cwd.

If that fails, you can use the locate command to search for files with a certain name.

locate exhibitor-1.2.3-jar-with-dependencies.jar

The locate command searches an index which is updated every night (or at variable times if you turn off your computer at night), so if you installed the file recently, you might not find it that way.

In desperation, you can use the find command to look for the file in a directory hierarchy. For example, if you suspect the file is under your home directory:

find ~ -name exhibitor-1.2.3-jar-with-dependencies.jar

To look everywhere in the system directories:

find / -xdev -name exhibitor-1.2.3-jar-with-dependencies.jar
share|improve this answer
add comment

You can read the current directory of the process:

readlink /proc/1615/cwd

This will only work to determine that relative path if the process did not change it's working directory since it was executed. Another thing to note is that processes can change their command name (what is displayed in PS), so it should not be relied on.

share|improve this answer
add comment

Use find

find / -name exhibitor-1.2.3 -type d -print

This will find all directories name exhibitor-1.2.3 on your system.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.