PHP’s max_execution_time Different on Windows and Linux

On Windows, the PHP INI variable, “max_execution_time,” is the maximum clock time between when the PHP process starts and when it finishes.

On Linux and OS X, the same variable represents the maximum CPU time that the PHP process can take.  CPU time is less than clock time because processes on Linux (and OS X) contend for CPU time, and sometimes sit idle.

For example, if you have a PHP program which makes a request to a web service, like FileMaker’s Custom Web Publishing, on Linux, the time the PHP program waits for a response is not counted, while on Windows, it does. You can see this by running the script:

<?php
    set_time_limit(15); /* Sets max_execution_time */
    sleep(30); /* Wait thirty seconds */
    echo "Hello World!n";
?>

If you run this on Windows, it will fail with an error message. However, on Linux or OS X, the time spent sleeping is is “idle” time, and the execution time is considered to be almost zero.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top