I am running some php exec commands on PHP - CLI Some of these exec() take too long.
So my idea is to setup a 60 seconds timeout on the exec()
I found some solutions for Linux, but I could not adapt them on windows (pipe/processes...)
Any idea on how to trigger a timeout on windows php cli exec() command ?
$intExecutionTimeout = 60;
$strCommand = 'wget http://google.com';
$strCommand = 'timeout --signal=15 --kill-after=' . ( $intExecutionTimeout* 2 ) . 's ' . $intExecutionTimeout . 's ' . $strCommand . ' &';
exec( $strCommand, $arrstrResponse );
try timeout command in CLI:
$time = 60;
$command = 'wget http://google.com';
exec(sprintf("C:\Windows\System32\timeout.exe /t %d %s", $time, $command), $output);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.