在Ubuntu中配置inotify,要点如下:
sudo apt update和sudo apt install inotify-tools命令安装inotify-tools软件包。grep CONFIG_INOTIFY /boot/config-$(uname -r)命令检查内核是否支持inotify。cat /proc/sys/fs/inotify/相关命令查看max_user_watches、max_user_instances和max_queued_events等参数。sudo sysctl -w命令临时修改参数,如sudo sysctl fs.inotify.max_user_watches=524288。/etc/sysctl.conf文件,添加或修改参数,然后使用sudo sysctl -p使配置生效。inotifywait或inotifywatch命令监控文件或目录,可通过参数设置监控模式、事件类型等。