Reputation: 445
I have this strange problem when i run an import cronjob in made. It processes a 1.5GB XML file containing about 400.000 products. The script works fine and would take multiple hours to complete, but after about 500/600 seconds i get the following email from the cron-deamon.
PHP Warning: file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport&cron): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /home/test.nl/public_html/admin/controller/tool/EZImport_cron.php on line 8
Warning: file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport&cron): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /home/test.nl/public_html/admin/controller/tool/EZImport_cron.php on line 8 bool(false)
My apache error-logs say:
[Fri Nov 02 09:43:39 2012] [warn] [client 176.9..174] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server [Fri Nov 02 09:43:39 2012] [error] [client 176.9..174] Premature end of script headers: cron_index.php
This is the cron file called by the cronjob
require_once('../../config.php'); $opts = array('http' => array('timeout' => 36000) ); $context = stream_context_create($opts); $url = HTTP_SERVER."cron_index.php?route=module/cronMod&cron"; $result = file_get_contents($url, false, $context); var_dump($result); die();
I need to run this cron via file_get_contents
Environment:
DEBIAN, OpenCart
The max execution time in webmin (php config) is set to 36000 seconds.
Upvotes: 3
Views: 2140
Reputation: 48357
processes a 1.5GB XML file
Erk, this is a bit silly - you need a minimum of 2 passes to verify the document is well formed and there's lot's of scope for bad things to happen.
The max execution time in webmin (php config) is set to 36000 seconds
For which end?
You also need to configure the timeout for the webserver and every other component in the chain between client and server, however trying to transfer a 1.5Gb file over HTTP is just silly - you might get it to work - but it's not the right way to solve the problem. Break it up into more manageable chunks.
Upvotes: 1
Reputation: 30565
Try using set_time_limit(0)
in the script or change the time limit in php.ini
Upvotes: 0