我正在使用这个包来运行我的 bash:
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
当我想在 laravel 中运行我的 bash 时出现这个错误:
The process ***/my.sh exceeded the timeout of 60 seconds.
$process = new Process('sh ***/my.sh');
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
我在 phpinfo
函数中的 max_execution_time
是 240。我重新启动了我的服务器。
我的 safe_mode
已关闭。我使用了这个功能:
set_time_limit(0);
在我的代码上方,但 60 秒后我收到相同的错误消息。
我的 .htdaccess
是 240 秒。
有什么想法吗?
最佳答案
根据 Process docs,Process
类有自己的超时时间:
By default processes have a timeout of 60 seconds, but you can change it passing a different timeout (in seconds) to the
setTimeout()
method:
use Symfony\Component\Process\Process;
$process = new Process('sh ***/my.sh');
$process->setTimeout(240);
$process->run();
您还应该检查 idleTimetout
,如果该过程可能需要很长时间而没有输出任何数据:
$process->setIdleTimeout(240);
文档没有说明将 0
用作无限制。
关于php - max_execution_time 为 240 秒 - 超过 60 秒的超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61016129/