Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. Also, ps -ef showed that the process with that pid is /usr/bin/httpd (apache), so it must have been apache serving some perl page I suppose.

Is it possible to get the path to currently running perl script, if I only know the process PID of the perl process that is running that script? 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
ps aux should tell you when the perl process was started, combine with Apache access logs to find the responsible script. – Daniel Beck May 1 '11 at 14:30
up vote 1 down vote accepted

You can do ps -p $p -o command , where instead of $p you use the PID of the process. This gives the full command line.

share|improve this answer

Take a look in /proc for the PID of the process. In there is a file cmdline

That contains the command that was used to run the script.


$ cat /proc/19433/cmdline

There is actually \000 (chr(0) / NULL) between the "perl" and the "/path..." but cat doesn't show it.

share|improve this answer
I also just found out by accident, that pressing c while viewing "top" output gives the full command names. Neat :) – Kipras Jul 29 '11 at 9:22

Your Answer


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.