次のスクリプトは、フォルダー/dev/shm/test
を監視し、作成されたファイルをリアルタイムで出力します。
<?php
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "a") // stderr is a file to write to
);
$cwd = '/tmp';
$env = array('some_option' => 'aeiou');
$process = proc_open('inotifywait -mc -e create /dev/shm/test/', $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
header("Content-type: text/html;charset=utf-8;");
ob_end_flush(); //ends the automatic ob started by PHP
while ($s = fgets($pipes[1])) {
print $s;
flush();
}
fclose($pipes[1]);
fclose($pipes[0]);
fclose($pipes[2]);
// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);
echo "command returned $return_value\n";
}
?>
問題は、それが終わることはなく、永遠に続くことです。なぜこれが起こっているのかについての手がかりはありますか?私はmax_execution_time = 30
php.iniにあります
このスクリプトが使用するリソースの数を監視するにはどうすればよいですか?
どうもありがとう。