以下是一些Ubuntu下inotify的实用技巧:
sudo apt-get install inotify-tools
安装。inotifywait -m /path/to/file_or_directory
命令持续监控,-r
选项可递归监控子目录,-e
选项指定监控事件类型,如create
、delete
、modify
等。-t
选项设置超时时间,--format
和--timefmt
选项可自定义输出格式。-d
选项将inotifywait作为守护进程运行,-o
选项指定日志文件。/proc/sys/fs/inotify/
下的相关文件,增加max_user_watches
、max_user_instances
等参数的值,以适应大规模监控需求。