PHP maximum execution time

2019-04-12 18:30发布

问题:

In my Plesk 11, PHP 5.4.7. Apache/2.4.3 system, when I make cron jobs I get this error from error.log file.

[Tue Mar 19 21:33:18 2013] [warn] [client 88.44.55.66] mod_fcgid: read data timeout in 45 seconds
[Tue Mar 19 21:33:18 2013] [error] [client 88.44.55.66] Premature end of script headers: index.php

So I checked for execution time with this:

echo ini_get('max_execution_time');

I got this value: 1560000

It doesn't seem a timeout problem but I get timeout error?

Answer for the future reference:
Edit /etc/httpd/conf.d/fcgid.conf file with vim.
Change FcgidIOTimeout 45 to FcgidIOTimeout 600.
Restart Apache. Then Fast CGI timeout will be solved.

回答1:

That's a mod_fcgid timeout, not a PHP timeout. Take a look at the mod_fcgid documentation to find out how to change it, especially at FcgidIOTimeout.



回答2:

Cron scripts if build correctly should not be run through apache. Your error shows that you are running into a timeout set by mod_fcgi.



回答3:

If you access it through http in your cronjob, then it will work as a webpage request and then it may be affected by apache timeout because apache is involved in the process. You can run the php script directly with an absolute path using php interpreter to bypass apache