![](/img/trans.png)
[英]How to execute external windows software command line in php exec()?
[英]How to setup a timeout on PHP exec() command on Windows?
我在PHP-CLI上運行一些php exec命令。這些exec()中的一些花費太長時間。
所以我的想法是在exec()上設置60秒超時
我找到了一些適用於Linux的解決方案,但無法在Windows上使用它們(管道/進程...)
關於如何觸發Windows php cli exec()命令超時的任何想法嗎?
$intExecutionTimeout = 60;
$strCommand = 'wget http://google.com';
$strCommand = 'timeout --signal=15 --kill-after=' . ( $intExecutionTimeout* 2 ) . 's ' . $intExecutionTimeout . 's ' . $strCommand . ' &';
exec( $strCommand, $arrstrResponse );
在CLI中嘗試timeout命令:
$time = 60;
$command = 'wget http://google.com';
exec(sprintf("C:\Windows\System32\timeout.exe /t %d %s", $time, $command), $output);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.