Unable to monitor filesystem using inotify??

Mohit Sethi
Appliedcode
Published in
1 min readDec 1, 2016

Well, Listen (inbuilt Linux command) uses inotify by default on Linux to monitor directories for changes. It’s very common to encounter with the system limit on the number of files to be monitored.

You can get the your current inotify set limit, execute below command:

$ cat /proc/sys/fs/inotify/max_user_watches

When this limit is not enough to watch files inside the directory, you can increase it as per your usage using below commands for temporary set limit:

$ sudo sysctl fs.inotify.max_user_watches=524288
$ sudo sysctl -p

If you want to set the limit permanently, use:

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p

You may also need to keep tracks of values of max_queued_events and max_user_instances.

Quicker way to set limit to inotify watchers:

  • If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:
  • echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
  • If you are running ArchLinux, run the following command instead
  • echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl — system

Cheers!!

--

--

Mohit Sethi
Appliedcode

OpenSource | DevSecOps | DataScience | Machine Learning | ChatBots | Robotic Process Automation(RPA) | Coffee lover | Codes for a better world | Opinions = Mine