Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I had a problem recently, where a perl script was consuming server resources. I found out it was a perl script by using "top". But it didn't give the path to the script. Nor did "ps".

Is it possible to get the paths to currently running perl scripts? If so, how?

Clarification : i don't need the path to the perl binary, i need the path to the perl script that binary is currently executing.

share|improve this question

closed as off topic by Chopper3 Apr 29 '11 at 16:48

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What options did you use with ps? ps -ef should give you the full path to what is running. –  Flashman Apr 29 '11 at 15:04
    
Dupe of superuser.com/questions/103309/…, where it's better asked anyway. –  Chopper3 Apr 29 '11 at 16:48
    
I would disagree this is a dupe of that question, because the absolute path to the running process in this case would be the path to perl binary. I need to know the path to the script that the perl binary is currently executing. I have probably not written the question clear enough.. –  Kipras May 1 '11 at 14:11

2 Answers 2

First get the pid from ps aux or ps -ef (it's the second column). Suppose it's 42. Then do (as root):

ls -l /proc/42/exe

To get a list automatically you can use something like this:

for pid in `ps auxwww | grep perl | grep -v grep | awk '{print $2}'`; do ls -l /proc/$pid/exe; done
share|improve this answer

You can always try to locate the PL file on your filesystem (using find, locate, etc). If you have multiple PL files with the same name, you'd have to dig deeper: something like dstat, if available for your distro, could be a good option.

share|improve this answer

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