Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running some php installation script from a browser and it's been running for a quite long time. Is there a way to check if it is still running on a server or timed out already? The browser is still showing loading spinner, but it is not a reliable progress indicator I suppose.

(Apache webserver under Linux)

share|improve this question
up vote 0 down vote accepted

mod_status/Server-Status should do the trick.

<Location /server-status>
    SetHandler server-status

Uncomment the above lines in your httpd.conf,

Then hit yoursite-or-ipaddress/server-status.

You should see a list of all the requests apache is working on, as well as that basic status of each one.

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

Srv PID Acc M   CPU     SS  Req Conn    Child   Slot    Client  VHost   Request
113-812 -   0/0/496 .   6.21    3025    2589    0.0 0.00    32.97   GET /images/Image/inside_repeat.png HTTP/1.1
share|improve this answer
Thanks, but that requires apache restart, isn't it? So I need to be prepared upfront. – serg Apr 28 '10 at 0:14
pretty sure it needs just a reload, which should keep your running script going. – GruffTech Apr 28 '10 at 15:27

If I'm not mistaken, the browser will run until the script is finished either by timeout, by memory exhaustion, or any other method that would kill the script on the server. I have some data processing scripts that run for 30 minutes or so. There nothing that I know of that would cause the browser state to freeze thinking the script is still loading after it has timed out on the server.

If you still want to monitor the script, the only way that I know of doing this would be to execute the script in the background, and check to see if the process is still running every few seconds. Since php isn't asynchronous like Java, it takes some hacking to get a function like this to work.

You would want to execute the script in the background:

exec('/path/to/php -f /path/to/script.php > /dev/null 2>&1 & echo $!',$op);
$pid = (int)$op[0]; 

Then, you can use a function like this to check if a process is still running.

   function isRunning($pid) {
        exec("ps $pid", $ProcessState);
        return(count($ProcessState) >= 2);

Then you would use

while(isRunning($pid)) {
echo 'Still running...';
//or something like this
share|improve this answer

Your Answer


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.