我在運行導入cronjob時遇到了這個奇怪的問題。 它處理一個包含大約400,000個產品的1.5GB XML文件。該腳本工作正常,並將需要幾個小時才能完成,但約500/600秒後,我從cron-deamon得到以下電子郵件。500秒後通過對等方重置連接
PHP的警告:的file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport &的cron):未能打開流:HTTP請求失敗! HTTP/1.1 500內部服務器錯誤 在/home/test.nl/public_html/admin/controller/tool/EZImport_cron.php第8行
警告: 的file_get_contents(http://test.nl/admin/cron_index .php?route = module/EZImport & cron): 無法打開流:HTTP請求失敗! HTTP/1.1 500內部 服務器錯誤 /home/test.nl/public_html/admin/controller/tool/EZImport_cron.php 上線8布爾(假)
我的Apache的錯誤日誌說:
[週五11月2日9點43分39秒2012] [警告] [客戶端176.9..174](104)通過對等連接復位:mod_fcgid:從FastCGI的服務器 錯誤讀取數據[週五11月2日9點43分:39 2012] [error] [client 176.9..174]腳本標題過早結束:cron_index.php
這是由的cronjob稱爲cron的文件
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();
我需要運行通過的file_get_contents
這個cron的環境:
Debian,請 Opencart的
中最長執行時間webmin(php config)設置爲36000秒。
Mod_fcgid(和它的apache2模塊等價物)確實不適合運行這樣的長期任務。儘管您指定'需要'使用'file_get_contents'方法來運行此cron,但您應該考慮將您的cron作業切換爲使用CLI版本的PHP,但不會受到其他SAPI強加的時間限制。 –