inotify.php 451 B

123456789101112131415
  1. <?php
  2. //创建一个inotify句柄
  3. $fd = inotify_init();
  4. //监听文件,仅监听修改操作,如果想要监听所有事件可以使用IN_ALL_EVENTS
  5. $watch_descriptor = inotify_add_watch($fd, __DIR__.'/inotify.data', IN_MODIFY);
  6. swoole_event_add($fd, function ($fd) {
  7. $events = inotify_read($fd);
  8. if ($events) {
  9. foreach ($events as $event) {
  10. echo "inotify Event :" . var_export($event, 1) . "\n";
  11. }
  12. }
  13. });