0

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.

Kipras
  • 101
  • 1
  • 3
  • 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 http://superuser.com/questions/103309/how-can-i-know-the-absolute-path-of-a-running-process, 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 01 '11 at 14:11

2 Answers2

1

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
Eduardo Ivanec
  • 14,881
  • 1
  • 37
  • 43
0

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.

Gaia
  • 1,855
  • 5
  • 34
  • 60