PHP script timeout in Log Analyzer - php

I have been trying to get Log Analyzer to work for longer than I care to admit. I can't seem to get syslog messages to display in the Log Analyzer web-GUI, but this morning I got the following error:
"While reading the logstream, the php script timeout forced me to abort at this point. If you want to avoid this, please increase the LogAnalyzer script timeout in your config.php. If the user system is installed, you can do that in Admin Center."
I was not getting this error on Friday; only "No syslog records found." The timeout is set to 30 seconds in the config file, but I read that setting will get overwritten back to the default anyway. The database grew to over 4GB over the weekend. Does the the db size have anything to do with this?
It's pretty clear I am new to php and Log Analyzer, so any help with both would be greatly appreciated. I can post config file settings if needed.

Try to increase time. 30 second may be not enough for parse large file. For example set 600 seconds.
Another case to increase timeout - edit following line in php.ini file
; Duration of time, in seconds for which to cache realpath information for a given
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
max_execution_time = 30;

Too many records in the database, the script does not have enough time to process everything. I keep the last 14 days in the database, that's enough.
USE Syslog;
DELETE FROM Syslog.SystemEvents WHERE ReceivedAt < DATE_SUB(NOW(), INTERVAL 14 DAY);

Related

mysql server is responding too slow or not responding

I use mysql through phpmyadmin interface. i have no problem with the apache server. It responded,as it was before. But when i am trying to access the phpmyadmin page, the page is loading with a huge time. After a long time it came with a message
`Fatal error: Maximum execution time of 30 seconds exceeded in
C:\xampp\phpMyAdmin\libraries\classes\Dbi\DbiMysqli.php on line 213
` i have changed the value of the variable
$cfg['ExecTimeLimit']
from 300 t0 1200. I think for that, i am able to see the loaded page. But, after loading i can't do anything with the interface as it takes too much time to respond.
I have tried the mentioned things in the following link
WAMP/XAMPP is responding very slow over localhost
can anyone help me out to get rid of this problem, it's really waste a huge time of mine from several days
I was having the same problem you could edit your php.ini file and set the max_execution_time = 120. But this isn't always working. Another suggestion is the past this two lines in your code. This solved my problem. It will affect the execution time of the script itself so it will get more time to run then the 30 seconds.
ini_set('max_execution_time', 300);
set_time_limit(0);
I don't know if you use this but this is the easiest way to visualise the errors.
error_reporting(E_ALL);
ini_set('display_errors', 1);

TCPDF Maximum execution time exceed 30 seconds

Can somebody please help me how to fix this error. I have a pdf page and I made a custom page size and made it landscape.
But when I run the page. It has an error saying "Maximum execution time exceeded 30 seconds in tcpdf.php line 18385
It only appears when I uploaded it in the server.
But when I use the program through remote it runs.
What seems to be the problem?
I had this issue as well on some content-heavy PDFs. PHP by default only allows a maximum execution time of 30 seconds.
You can increase this time in the php.ini file by changing the following line:
max_execution_time = 30
to
max_execution_time = 60
or adding this to the top of your script file.
set_time_limit(60);
60 seconds should be enough time for TCPDF to do what it needs to do but you may need to increase it further. Be careful with increasing it too much, however, as it can cause issues.
NOTE: If you're reaching the maximum execution time due to an infinite loop, this won't change anything.
you can use ini_set("you php config",0);

PHP Time Execution & Show content in browser when it ready?

First of all the script take sometimes to execute and it stops after 30 seconds. Says that the execution time is max about 30 seconds (I know that we can change this param in the httpconf)
but I don't know the max execution time may be 1 hour or more.
So I want to know if there is no time limit execution in php?
Second question: how to show the content in a browser when it's ready and continue the execution, because I always wait the script to end in order to see the content displayed in the browser.
Next time you post a question, make sure to research it better. Both questions are well documented on stackoverflow and the internet.
now to your answer...
To let it run until finished regardless of the time it takes:
http://www.php.net/manual/en/function.set-time-limit.php
set_time_limit(0);
To display content right after it is generated:
http://www.php.net/manual/en/function.flush.php
ob_flush();
flush();
A script that might run that long should be run from the console. Browser timeouts could also interfere with running it via browser.
If you use a console script, you could route the output into a database and query it from there.
You have in php.ini this code. I am not sure you could check it from elsewhere than php.ini.
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30
You can't do that in php. The script runs until it finishes execution (normal, or error).

time of 30 seconds exceeded error? file get contents

i have this error:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\AppServ\www\facebook\classes\burccek.class.php on line 56
(im using file_get_contents)
(in this program i post file_get_contents data to facebook user wall(offline_access))
It means the file_get_contents operation takes more time that the max execution time of PHP. If you need a longer time, add this line at the top of your file: set_time_limit($seconds);
However 30 seconds seems a long time already so there might be some other issue with your application.
If duration of posting file to FB is longer than 30s (default maximum execution time of php script), use
set_time_limit ( 120 );
(or more in seconds) before executing file_get_contents
When posting data to other URLs, you should rely on CURL or even in extreme case may go to socket level. Curl has better control on connection time outs to handle network latency, much more set of options. In some hosting environments or servers a sys admin may restrict what all php.ini settings you can change, though you can change set_time_limit
You can change your set_time_limit in your php.ini file to alter the maximum execution time that php can use for a script.

PHP Script Times out after 45 seconds

I am running a huge import to my database(about 200k records) and I'm having a serious issue with my import script timing out. I used my cell phone as a stop watch and found that it times out at exactly 45 seconds every pass(internal server error)... it only does about 200 records at a time, sometimes less. I scanned my phpinfo() and nothing is set to 45 seconds; so, I am clueless as to why it would be doing this.
My max_execution_time is set to 5 minutes and my max_input_time is set to 60 seconds. I also tried setting set_time_limit(0); ignore_user_abort(1); at the top of my page but it did not work.
It may also be helpful to note that my error file reads: "Premature end of script headers" as the execution error.
Any assistance is greatly appreciated.
I tried all the solutions on this page and, of course, running from the command line:
php -f filename.php
as Brent says is the sensible way round it.
But if you really want to run a script from your browser that keeps timing out after 45 seconds with a 500 internal server error (as I found when rebuilding my phpBB search index) then there's a good chance it's caused by mod_fcgid.
I have a Plesk VPS and I fixed it by editing the file
/etc/httpd/conf.d/fcgid.conf
Specifically, I changed
FcgidIOTimeout 45
to
FcgidIOTimeout 3600
3600 seconds = 1 hour. Should be long enough for most but adjust upwards if required. I saw one example quoting 7200 seconds in there.
Finally, restart Apache to make the new setting active.
apachectl graceful
HTH someone. It's been bugging me for 6 months now!
Cheers,
Rich
It's quite possible that you are hitting an enforced resource limit on your server, especially if the server isn't fully under your control.
Assuming it's some type of Linux server, you can see your resource limits with ulimit -a on the command line. ulimit -t will also show you just the limits on cpu time.
If your cpu is limited, you might have to process your import in batches.
First, you should be running the script from the command line if it's going to take a while. At the very least your browser would timeout after 2 minutes if it receives no content.
php -f filename.php
But if you need to run it from the browser, try add header("Content-type: text/html") before the import kicks.
If you are on a shared host, then it's possible there are restrictions on the system when any long running queries and/or scripts are automatically killed after a certain length of time. These restrictions are generally loosened for non-web running scripts. Thus, running it from the command line would help.
The 45 seconds could be a coincidence -- it could be how long it takes for you to reach the memory limit.. increasing the memory limit would be like:
ini_set('memory_limit', '256M');
It could also be the actual db connection that is timing out.. what db server are you using?
For me, mssql times out with an extremely unhelpful error, "Database context changed", after 60 seconds by default. To get around this, you do:
ini_set('mssql.timeout', 60 * 10); // 10 min
First of all
max_input_time and
set_time_limit(0)
will only work with VPS or dedicated servers . Instead of that you can follow some rules to your implementation like below
First read the whole CSV file .
Then grab only 10 entries (rows) or less and make a ajax calls to import in DB
Try to call ajax every time with 10 entries and after that echo out something on browser . In this method your script will never timeout .
Follow the same method untill the CSV rows are finished .

Categories