Help figuring which php script is endless looping

ok, I have a dedicated server with a good number of websites on it. One of the users on my server has about a dozen sites. One of these sites has a php script that is getting in an endless loop, but I dont know which script.

If I log in through ssh right now and run top, I see about 10 copies of php5.cgi running under this user each with between 30 and 350 cpu minutes. and they all are taking between 5 and 10% cpu load.

Now I know how to kill a process, but what I dont know is how to determine which script it is running.

Is there an easy way to get a list of what files a given PID has open?


Use the ‘lsof’ (list open files) command.


runing lsof, i got this:
bash: lsof: command not found

but, the dh admins emailed me back right after you replied suggesting that i try:
ps aux | grep troutslapped | awk ‘{print $2}’ | xargs -t -ipid cat /proc/pid/environ

which didnt seem to do anything either, but it got me thinking in the right direction. since all of the coppies were on the list when i ran top, i just got their pid’s from that.

sudo cat /proc/4105/environ

or whatever the id was, and it got me an ugly looking list of enviroment variables, but i was able to look through it for the script_url and find that it was a file called dl.php from gmail lite in every single one of em.

so i renamed that file and left a note on the login page of gmail lite that it might be broken, but the rest of my server is now working.

thanks for the reply though!