inotify,实时监控文件变化

阅读 118

2023-01-31


inotify,PHP的一个扩展,用于监控文件变化

<?php
$fd = inotify_init();
$file = "/www/web/gateway/servers/LoanServer.php";
$watch_descriptor = inotify_add_watch($fd,$file,IN_MODIFY);
while(true)
{
$events = inotify_read($fd);
if($events)
{
$out = shell_exec('pkill -f LoanServer.php');
echo var_export($out,1); $output = shell_exec('/www/php/bin/php /www/web/gateway/servers/LoanServer.php');
foreach($events as $event)
{
//echo "inotify Event :".var_export($event, 1)."\n";
}
}
}
inotify_rm_watch($fd, $watch_descriptor);
fclose($fd);
?>

精彩评论(0)

0 0 举报