Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:34:23+00:00 2026-06-06T15:34:23+00:00

This is not one of the regular questions if sleep is counted for timeout

  • 0

This is not one of the regular questions if sleep is counted for timeout or stuff like that. Ok, here’s the problem: I’ve set the max_execution_time for PHP as 15 seconds and ideally this should time out when it crosses the set limit, but it doesn’t. Apache has been restarted after the change to the php.ini file and an ini_get(‘max_execution_time’) is all fine. Sometimes the script runs for upto 200 seconds which is crazy. I have no database communication whatsoever. All the script does is looking for files on the unix filesystem and in some cases re-directing to another JSP page. There is no sleep() on the script.

I calculate the total execution time of the PHP script like this:

At the start of the script I set :

$_mtime = microtime();  
$_mtime = explode(" ",$_mtime);
$_mtime = $_mtime[1] + $_mtime[0]; 
$_gStartTime = $_mtime;

and the end time($_gEndTime) is calculated similarly.
The total time is calculated in a shutdown function that I’ve registered:

register_shutdown_function('shutdown');
.............
function shutdown()
{
   ..............
   ..............
   $_total_time = $_gEndTime - $_gStartTime;
   ..............
   switch (connection_status ())
    {
    case CONNECTION_NORMAL:
      ....
      break;
      ....
    case CONNECTION_TIMEOUT:
      ....
      break;
      ......
    }
} 

Note: I cannot use $_SERVER[‘REQUEST_TIME’] because my PHP version is incompatible. That sucks – I know.

1) Well, my first question obviously is is why is my PHP script executing even after the set timeout limit?
2) Apache has the Timeout directive which is 300 seconds but the PHP binary does not read the Apache config and this should not be a problem.
3) Is there a possibility that something is sending PHP into a sleep mode?
4) Am I calculating the execution time in a wrong way? Is there a better way to do this?

I’m stumped at this point. PHP Wizards – please help.

Edit:
I just found out that the stream operations are not the cause with a few logs. The delay is just random within the script even when there are no streaming operations performed. Context switching may just be the reason. But I still dont have a clear answer. I looked up Real max_execution_time for PHP on linux but Im not sure I want to try that out. Any other suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:34:25+00:00Added an answer on June 6, 2026 at 3:34 pm

    max_execution_time only limits script execution time itself – cpu time of your script. if the OS context switched to another process and spent some time there, it will not be counted as well. So measuring the real-world time and expecting a timeout after 30 seconds is not going to be true any given time. And of course, it disregards any system, exec or network times as well

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is not a homework problem. This questions was asked to one of my
I am aware that there other questions like this, but their solutions do not
this one is not homework, it just the fact that i've been out of
My question is not like this one: Browser-independent way to detect when image has
This is not really a programming question, more of an algorithmic one. The problem:
I saw some other similar questions on this topic here but they were not
[NOTE: This questions is similar to but not the same as this one .]
I know this very regular question But i didn't get that's way ask here
I realize that similar questions have been asked about this before here on SO,
I've found some questions that seem related to this one, but none describes exaclty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.