With inotify
, you can efficiently watch your filesystem for changes and run commands based on the results.
You can get your current inotify file watch limit by executing:
$ cat /proc/sys/fs/inotify/max_user_watches
You may need to increase the number of files one user can watch with inotify. Many distributions have a default limit of 8192 watched files per user. The maximum amount is 524288. You can set a new limit temporary with:
$ sudo sysctl fs.inotify.max_user_watches=524288 $ sudo sysctl -p
To make it permanent, store it in the sysctl
config file.
fs.inotify.max_user_watches=524288
On Arch Linux, Fedora and other RPM-based distributions, you apply this with sudo sysctl –system
. On Debian, Ubuntu and many other systems, this has to be in /etc/sysctl.conf and you apply it with sudo sysctl -p
.
You may also need to pay attention to the values of fs.inotify.max_queued_events
and fs.inotify.max_user_instances
if watching is slow or hangs.
(source)
Non-exhaustive list of programs which use inotify to watch for changes and may have problems with restrictive limits: