2

I have a process running in the background, a python one, with ps -ef I can see filename from running command : UID PID PPID ... python ./filename.py

How can I know where the file is located

1 Answer 1

5

pwdx < PID > gives full directory the process is running from.

So, the full script would be

ps -ef | grep 'your process' | awk '{print $2}' | xargs pwdx

Though, you can simplify this into

pgrep 'your process' | awk '{print $1}' | xargs pwdx
Sign up to request clarification or add additional context in comments.

1 Comment

Worth noting that this only works as long as the running python process doesn't do os.chdir, which updates the process' cwd attribute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.