ubuntu 中 inotify 日志查看位置与方式
核心结论
- inotify 是内核机制,默认没有常驻的系统日志文件。要查看事件,需要由应用(如 inotifywait/inotifywatch)输出日志,或通过系统日志/内核环形缓冲查看与 inotify 相关的错误或告警信息。
查看方式与对应日志位置
快速排查清单
- 先确认工具是否可用:inotifywait --version;若未安装:sudo apt-get update && sudo apt-get install inotify-tools。
- 检查是否触发内核限制:cat /proc/sys/fs/inotify/max_user_watches;cat /proc/sys/fs/inotify/max_user_instances;cat /proc/sys/fs/inotify/max_queued_events。必要时可临时调高(需 root):echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf;echo fs.inotify.max_user_instances=1024 | sudo tee -a /etc/sysctl.conf;echo fs.inotify.max_queued_events=1048576 | sudo tee -a /etc/sysctl.conf;sudo sysctl -p。
- 若怀疑事件未被捕获或服务异常,查看系统日志:dmesg | grep inotify;journalctl -xe | grep inotify。