1

我有一个带有 xfce 窗口管理器的系统 fedora 15。

我安装了一个 inotify util 来玩。

我想控制在我的工作过程中我的文件会发生什么。我今天使用一个命令来运行 inotify

inotifywait --fromfile ~/list.inotify

该命令可以轻松读取要读取和忽略的文件夹和文件列表。有我的清单(list.inotify)

/home/alex

@/home/alex/Torrnets/
@/home/alex/.pulse-cookie

所以它应该读取我的主文件夹并忽略 Torrents 文件夹和 .pulse-cookie 文件。

它也忽略了 Torrent。但它不会忽略 .pulse-cookie 文件。

有什么解决方案吗?(请不要发布使用基于模式的忽略的解决方案,我想使用具有绝对路径的文件列表)

$man inotify
   @<file>
          When watching a directory tree recursively, exclude the specified file from being watched.  The file must be specified with a relative or absolute path according to whether a relative or absolute path is given for watched directories.  If a  specific
          path is explicitly both included and excluded, it will always be watched.

          Note: If you need to watch a directory or file whose name starts with @, give the absolute path.

   --fromfile <file>
          Read filenames to watch or exclude from a file, one filename per line.  If filenames begin with @ they are excluded as described above.  If <file> is `-', filenames are read from standard input.  Use this option if you need to watch too many files to
          pass in as command line arguments.
4

1 回答 1

2

如果您不指定-e参数,inotifywait将调用inotify_add_watchwith IN_ALL_EVENTS,这会导致监视目录中的文件发生事件 - 请注意inotify(7)说:

在监控目录时,上面标有星号 (*) 的事件可能发生在目录中的文件上,在这种情况下,返回的 inotify_event 结构中的 name 字段标识目录中文件的名称。

如果您查看有问题的 inotifywait 代码,您会发现它只监视(并检查排除列表)目录。如果您在指定一个不是目录或从未使用过的排除项时被警告,它可能会更加用户友好,但这就是当前的方式。

于 2011-11-13T14:05:50.257 回答