【发布时间】:2015-08-27 06:07:10
【问题描述】:
我必须编写一个脚本来检查后台批处理正在进行的文件传输的进度。我知道文件夹需要具有“完整”状态的文件数。我正在后台 PHP 中尝试以下操作:
$id = $_GET['id'];
$qtd = $_GET['qtd'];
checkProgress($id, $qtd);
function checkProgress($qtd, $id) {
$dirWav = "D:\\path\\to\\wav\\".$id."\\";
$dirMP3 = "D:\\path\\to\\mp3\\".$id."\\";
$progWav = array_diff( scandir($dirWav), array(".", "..") );
$progMP3 = array_diff( scandir($dirMP3), array(".", "..") );
$numWav = count($progWav);
$numMP3 = count($progMP3);
if ($numMP3 < $qtd OR $numWav < $qtd) {
sleep(5);
checkProgress($qtd, $id); //Here i'm trying to do it in a recursive way
} else {
//End script, record to the DB
}
}
我确定被检查的文件夹在启动时是空的,并且批处理运行正常。但是在脚本开始的时候,它会自动走到最后(我用一个 mkdir 偷偷的检查了一下)。
我怎样才能实现我想要的?我无法通过 cronjob 或类似的方式检查它。
【问题讨论】:
标签: php batch-file background-process file-transfer