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.

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?

share|improve this question

1 Answer 1

up vote 5 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.

share|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

Your Answer

 
discard

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.