php - 触发inotify事件时如何运行php代码
问题描述
每当在 php 中更新文件(log.txt)时,我都会尝试重新加载框架。我想我可以用inotify_add_watch($inf, './log.txt', IN_MODIFY);
.
问题是,我是一个完整的 php 菜鸟,而文档对此没有帮助。当文件 IN_MODIFY 事件被触发时,我将如何运行一些代码?
到目前为止,我有
<html style='background-color:#202020;'>
<word style='color:#FFFFFF;'>
<head>
<meta http-equiv="refresh" content="2"/>
</head>
<body id="chat">
<?php
$log = file_get_contents('./log.txt');
echo $log;
$inf = inotify_init();
$watch = inotify_add_watch($inf, './log.txt', IN_MODIFY);
$events = inotify_read($inf);
//Run php code here when inotify event occurs
inotify_rm_watch($inf, $watch);
fclose($inf);
?>
</body>
</html>
如您所见,我设置了监视描述符和 inotify 实例,但我不知道如何使用该事件。
有任何想法吗?
解决方案
推荐阅读
- regex - 在 perl 中,当它之前至少有三个单词时匹配一个点
- mongodb - React-native:添加新项目后如何自动更新主屏幕
- android - 我如何在颤动的新容器上放置单词
- python - 如何在调用者的 try/except 之前拦截被调用模块函数中的错误
- wordpress - 如何获取任何 WordPress 主题和插件的挂钩
- net-snmp - NET-SNMP 中的异步调用并不是真正的异步
- c++ - 在保留顺序函数的同时删除向量中的重复项的逻辑错误
- hyperledger-fabric - Cli 服务可以存在于安装在不同机器(Hyperledger Fabric)中的每个组织上吗?
- java - 如何模拟 IMPLY 门?
- neo4j - 由于 Neo4J 中缺少属性,连接不起作用