LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 01-07-2009, 11:11 AM   #1
pawwa
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Rep: Reputation: 0
How to know what PHP script is hanging the CPU?


Hi LQ, this is my first post here, this is a great community.

I`m interested if anyone knows how could I find what particular php script (or java program, cgi, or whatever) is hanging the CPU, and running on apache web server? Is there a module for that?

Thanks.
 
Old 01-07-2009, 09:25 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
If you get control of the CPU again somehow, look in the Apache log to find out what the last-accessed script was.

It is important, though, to understand what you mean by "hanging". On my systems, each PHP script has a maximum time that it is permitted to run before the Apache web server kills it. In such a case, the browser that referred to the script will get no response, so it will appear that the server has hung, but in fact, the server is doing just fine.

To get more information on this, see if you can have a shell session to the server in parallel with the web browser. When the browser hangs, type a command to the shell session (top is a good choice); if the server is still alive, you will get a response to your command. Immediately visit the apache access log, and look at the recent entries there. You might also look at the error log, to see if there are any complaints about scripts taking too long. A good text editor running under your shell would be a great assist.
 
Old 01-08-2009, 06:02 AM   #3
pawwa
LQ Newbie
 
Registered: Dec 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks. I think this needs more discussion.

Quote:
Originally Posted by dkm999 View Post
On my systems, each PHP script has a maximum time that it is permitted to run before the Apache web server kills it.
Yeah, but a script could be access over and over again, and system could be less responsive.

Quote:
Originally Posted by dkm999 View Post
If you get control of the CPU again somehow, look in the Apache log to find out what the last-accessed script was.
What if we are talking about shared hosting environment, where there are hundreds of separate access logs. I mean, processing them all manually would be a pain in the ass.

I thought there was a module for this? I tried googling but I have found nothing.
 
Old 01-08-2009, 12:55 PM   #4
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
I am not aware of any module that can do this for you.

If this were my problem to solve in a shared host environment, I think I would not try to handle the mass of logfiles manually; that is what scripts are for. Digesting a list of logfiles would be pretty easy either using awk and sed or perl, depeding on which you are comfortable with.
 
  


Reply

Tags
apache, load, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php/shell script to install mysql,apache and php automatically stranger_6_7 Linux - General 2 08-11-2009 03:07 AM
how to autokill a hanging subprocess from a script WindowBreaker Programming 5 07-11-2008 03:16 AM
LXer: PHP apps: security's low-hanging fruit LXer Syndicated Linux News 0 01-11-2007 07:21 PM
LXer: Title: PHP/MySQL Classifieds Script AddAsset1.php Script Insertion LXer Syndicated Linux News 0 07-02-2006 07:21 PM
AWK script is hanging our server Hans Zarkoff Programming 10 08-20-2004 02:32 PM


All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration