简体   繁体   中英

Get source file path of a running python script from process id

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM