Is there a way to get the PHP script filename that is currently hammering my VPS?

For example, when I view "top", I see:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
7622 itil      17   0 61388  11m 6004 R 45.8  2.3   0:00.13 php
7626 itil      17   0 58360 8632 5440 R 24.6  1.6   0:00.07 php

How can I find out what file is being processed by PHP at that particular time?

link|improve this question

feedback

1 Answer

up vote 4 down vote accepted

To show the arguments passed to the comand, use the next command:

ps v -C php

If you just see something like php somefile.php, get the current working directory using:

readlink /proc/$PID/cwd

replace $PID by the PID of the process as shown by ps.

link|improve this answer
Thanks, ps does the job. Is there a way to get the arguments in top? – psynnott Mar 16 '11 at 16:06
3  
Press the "c" key while top is running. – BMDan Mar 16 '11 at 16:11
excellent stuff, thanks. – psynnott Mar 16 '11 at 16:56
feedback

Your Answer

 
or
required, but never shown

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