[Sussex] PHP process hogging the CPU

John Crowhurst fyremoon at fyremoon.net
Sat Aug 13 10:08:18 UTC 2005


On Fri, August 12, 2005 9:57, Brendan Whelan said:
> Hello,
>
> I have a PHP process which is probably in an endless loop. I have
> re-booted the system the process still continues. How can I find and stop
> the process which is hogging the time? (I have a long default php timeout
> set because, on occasions, some process need to run for an extended time.
> However, I will set the maximum time which each program can run on an
> individual basis.)

You could run top to show what processes are hogging CPU, once you have
the process id, you can kill it within top by pressing k and then the
process id followed by 9. Alternatively, you could grep for the process id
in ps:

ps auxwww|grep processid

The extra w's give a more verbose response to ps, hopefully you may see
the offending php script.

You could run strace -p processid to show what exactly the process is
doing in its endless loop.

You may find some solace in the server logs, perhaps you might see if its
a php script accessed a lot. Once you know the name you can isolate it and
study to see if you can workaround or fix the code issue.

If you kill the webserver, does the php process die as well?

--
John




More information about the Sussex mailing list