Configuring Linux for Many Watch Folders
To run many (>100) push Watch Folders on Linux computers, adjust three system settings and then reload the sysctl.conf file to activate them.
-
Increase the maximum number of watches allowed by the system.
Retrieve the current value by running the following command:
$ cat /proc/sys/fs/inotify/max_user_watches 8192
To permanently increase the number of available watches (to a value that is greater than the number of files to watch, such as 524288), add the configuration to /etc/sysctl.conf:
$ sudo echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
-
Increase the maximum number of inotify instances, which correspond to the
number of allowed Watch Services instances.
Retrieve the current value by running the following command:
$ cat /proc/sys/fs/inotify/max_user_instances 128
On many systems, the default value is 128, meaning only 128 watches can be created. To permanently increase the number available (to a value that is greater than the number of desired Watch Folder instances, such as 1024), add the configuration to /etc/sysctl.conf:
$ sudo echo "fs.inotify.max_user_instances=1024" >> /etc/sysctl.conf
-
Increase the open file limit.
Retrieve the current value by running the following command:
$ cat /proc/sys/fs/file-max 794120
To permanently increase the open file limit (to a value that is greater than the number of desired watches, such as 2097152), add the configuration to /etc/sysctl.conf:
$ sudo echo "fs.file-max=2097152" >> /etc/sysctl.conf
-
Reload systemd settings to activate the new settings.
To reload systemd settings, either reboot the machine or run the following command:
$ sudo sysctl -p /etc/sysctl.conf