以下是在Ubuntu中使用inotify优化性能的方法:
sudo sysctl -w fs.inotify.max_user_watches=524288
(设置监控数量上限)。/etc/sysctl.conf
,添加fs.inotify.max_user_watches=524288
,然后执行sudo sysctl -p
。max_user_instances
(实例数上限)和max_queued_events
(事件队列长度)。inotifywait
等轻量级工具,或根据场景选择fswatch
等替代方案。