0
点赞
收藏
分享

微信扫一扫

inotify,实时监控文件变化

殇感故事 2023-01-31 阅读 95
phpPHP


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 条评论