开发者

How to set $cmd overtime in php?

<?php
$cmd = 'webscreencapture.exe http://www.youtube.com/watch?v=SLyG0mUnw4A e:\www\111\1.jpg';
sleep(1);
$cmd = 'webscreencapture.exe http://www.youtube.com/watch?v=izUxI-k01CU e:\www\111\1.jpg';
system($cmd);
?>

The webscreencapture always run wrong for cycle screenshot one image. How to set a overtime command for $cmd that it can terminated 3 seconds after running 开发者_运维问答the command. Thanks.


You should kill it after 3 seconds:

sleep(3);
system('taskkill -im webscreencapture.exe');

If you do not have taskkill, or want to use a more robust solution, try pskill in the PsTools suite.

Edit: If you want to kill the process inside PHP:

$proc = proc_open('webscreencapture.exe ...');
sleep(3);
proc_close($proc);
// or
proc_terminate($proc);

You may want to have a look at the PHP Process Control part of the manual.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜