简体   繁体   English

动态化索引新文件夹

[英]Inotify dynamically index new folders

Say for example you had a shell script that utilises inotifywait in the following form 假设您有一个shell脚本,该脚本使用以下形式的inotifywait

inotifywait -m -e create /home/user1/*/*

Essentially you are asking it to monitor all folders two levels under user1. 本质上,您是在要求它监视user1下两个级别的所有文件夹。 I've noticed with inotify that it can not dynamically index new folders. 我注意到inotify不能动态索引新文件夹。

For example you have a file system like 例如,您有一个类似的文件系统

/home
     /user1
           /a
             /b

Then you run the inotifywait script, it will monitor actions on the 'b' folder. 然后运行inotifywait脚本,它将监视'b'文件夹中的操作。 If you were to then add a new folder 'c' under 'a' (same level as 'b'), inotify will not monitor actions on this folder. 如果要在“ a”(与“ b”相同的级别)下添加新文件夹“ c”,则inotify将不会监视该文件夹上的操作。 Anyone got a way of remedying this? 有人有办法解决吗?

Go up a level and monitor that with the recursive switch. 上一个级别并使用递归开关监视它。

inotifywait -r -m -e create /home/user1/*

I don't know what you are using this for, but for indefinite watching you might want to check out iwatch . 我不知道您使用它的目的是什么,但是对于无限期观看,您可能想要查看iwatch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM