要監視特定的腳本max_execution_time
,我用PHP ini_set max_execution_time nog工作正常嗎?
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
在我的腳本的頂部。然而,當我建立同一個文件的記錄,它返回我下面的:
25-09-2017 23:08:01|STARTED
25-09-2017 23:09:01|ALREADY RUNNING
25-09-2017 23:10:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 01:09:01|ALREADY RUNNING
26-09-2017 01:10:01|ALREADY RUNNING
26-09-2017 01:11:01|STARTED
26-09-2017 01:12:01|ALREADY RUNNING
26-09-2017 01:13:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 03:10:01|ALREADY RUNNING
26-09-2017 03:11:01|ALREADY RUNNING
26-09-2017 03:12:01|STARTED
26-09-2017 03:13:01|ALREADY RUNNING
26-09-2017 03:14:02|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 05:09:01|ALREADY RUNNING
26-09-2017 05:10:02|ALREADY RUNNING
26-09-2017 05:11:01|STARTED
26-09-2017 05:12:01|ALREADY RUNNING
26-09-2017 05:13:02|ALREADY RUNNING
26-09-2017 05:14:01|ALREADY RUNNING
...................|ALREADY RUNNING
26-09-2017 07:14:01|ALREADY RUNNING
26-09-2017 07:15:01|ALREADY RUNNING
26-09-2017 07:16:01|STARTED
的...................|ALREADY RUNNING
代表多個消息重複其間的每一分鐘。
我做錯了什麼,因爲間隔不是10分鐘?
編輯:
while循環,我有:
while (true) {
//DO PROCESSING WHEN FILES ARE PRESENT
Sleep(1);
}
你是否檢查過你的實際超時限制是用phpinfo(),並用瀏覽器加載頁面? 如果您正在運行php-fpm和nginx或任何舊的「Apache和PHP」限制,實際的時間限制可能會被設置,並覆蓋PHP自己的php.ini,否則在哪裏。 – DocWeird
@DocWeird,我用cronjob運行腳本。 phpinfo表示最大。對於本地值和主值,執行時間均設置爲30。 –
您是否在腳本中使用sleep -command? IIRC使用睡眠不會增加執行時間。 – DocWeird