Getting a PHP maximum execution time error - php

I'm getting a PHP "Maximum execution time of 60 seconds exceeded" error even though the max_execution_time and max_input_time settings in my php.ini are set to 180. I also tried to make my script use set_time_limit(0); and ini_set('max_execution_time', 180); and that's not helping. I've made sure the right php.ini file is being used, checked phpinfo() output, all the setting values are what I'd expect them to be. The line of code throwing the error is calling curl_exec(), so I also try to add curl_setopt($ch, CURLOPT_TIMEOUT, 180); and no luck, still getting the same 60 second timeout error. Running out of ideas as to what other timeout setting could possibly be causing this. Environment is Windows with PHP running as FastCGI module.

Run ini_get() precisely where the call is failing and see if it yields the value expected. If not, searched your code for something overriding the value you're expecting.

Related

Fatal error: Maximum execution time of 30 seconds exceeded. How to handle this error?

I am getting this error while running one script.
I know it's about execution time and i had went through all answers too but i want to display custom message when this error occurs so that site doesn't break.
How to handle that error as i have kept error display off on my live site so footer is not loaded due to this error which stops breaking my site?
http://whois.icann.org/en/lookup?name=google.com
When you visit this site its displaying custom error message
You can either increase the maximum execution time by using set_time_limit() or by setting max_execution_time in the php.ini.
Also by setting set_time_limit to 0 you can remove the limit for exceution time.
And if you are using linux you can try with the function register_shutdown_function.This function will be called when the execution time limit is reached.
You can try to add this line of code in the file first:
set_time_limit(0)
You can always modify your php.ini file. There is a setting for maximum execution time.
Another way is to use ini_set function.
Another way is to put the max execution time in your htaccess file.
EDIT:
The max execution time is not an error and therefore not catchable.
Please check out this: http://stackoverflow.com/questions/6861033/how-to-catch-the-fatal-error-maximum-execution-time-of-30-seconds-exceeded-in-p
Finally, there is always scope of fixing the scripts and putting lengthy processes into a queue.
you can exceed max execution time like this :
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
change below configuration in php.ini
max_execution_time = 600;
max_input_time = 120;
max_input_nesting_level = 64;
memory_limit = 128M;
ini_set('memory_limit', '-1');
ini_set('max_execution_time', '10000');
at the first line of your php code

PHP Fatal error: Max execution time exceeded - EVEN after set_time_limit(0)

I keep running into the following PHP error when running my script
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\apps\sqlbuddy1.3.3\functions.php on line 22
I already put this in my PHP file, and I STILL get this error message.
#set_time_limit(0);
Am I missing something?
Edit: This error only shows up after SEVERAL minutes, not after 30 seconds. Could something also be delaying its appearance?
set_time_limit() has no effect when running in safe_mode:
This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.
You can check the value of safe_mode and max_execution_time with phpinfo().
Given the facts that you are using Windows and experiencing the timeout later than 30s you might have somewhere else in your code a reset of the timeout (set_time_limit(30)):
The set_time_limit() function [..] only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.
Search your code for:
ini_set('max_execution_time', 30)
set_time_limit(30)
Rather than relying on the PHP file to change the php.ini settings, you should do it yourself. Find where the php.ini is kept for WAMP, and change/add this line:
max_execution_time = 500;
There is a PHP config that unallows the script to change the time_limit.
You can change your PHP behavior on php.ini file

504 Gateway Time-out Error on PHP Script

I coded a script for database import, it makes a few jobs on database. When I work this script, after a few minutes I'm getting "504 Gateway Timeout Error".
I increased all timeout values on php.ini, also I increased execution times but it is still same.
You can increase maximum execution time in php.
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
Write an info file on your server containing
<?php phpinfo();
View the file in your browser and check the max_execution_time
If it's 0 then there is something different to do else make sure you changed on correct ini file.
You can also check your ini file location
If you still can't fix it please reply :)

PHP set_time_limit not working for exec

I have a strange behavior of the time limit mgmt in PHP (v5.4.13).
I set max_execution_time to 30 in php.ini, in my script I call:
set_time_limit(1000) ;
and to be sure it is set I call:
error_log (ini_get('max_execution_time'));
which returns me 1000. But now if I call a program with
exec("foobar.exe") ;
(A long program, it takes about 5 minutes to run), the script stop with an error in the log:
PHP Fatal error: Maximum execution time of 120 seconds exceeded
My problem is why this script stops after 120 seconds? Any ideas?
Check your php.ini to see if Safe_Mode is ON. If so, max_execution_time has no effect.
OK, I found the issue.
That was stupid:
Between my set_time_limit(1000); and my exec("..."); I called few functions. Looking deeper in these functions, what a surprise! a set_time_limit(120);
Thanks everybody for your help!

Internal Server Error after long time running of php script

I have some db query in my php file, approximately after 40 second, happened INTERNAL SERVER ERROR, though in php.ini file this settings are set:
memory_limit 8192M
max_execution_time 120
I think this settingst is enough, other what reason may causes INTERNAL SERVER ERROR after long time running of php script?
set
ini_set('max_execution_time' ,0);
ini_set('set_memory_limit', -1)
The question is old but this might work for someone.
Use this for every iteration of your loop sleep(0.5);
0.5 is user defined you can change it.

Categories