Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Increase Inotify Watches

This tutorial will teach you how to increase the number of inotify watches in order to fix possible issues in Seafile, Sublime, and file browsers like Nautilus.

Background

The Linux kernel offers an interface — called inotify — which allows an application to obtain change notifications for files and directories, if the application has registered watches for the files and directories it is interested in.

The advantage of this is twofold: First, it is not necessary to perform regular filesystem scans to detect file changes, i.e. the I/O load is drastically reduced. Secondly, changes can be reported immediately, thus allowing faster responses.

Symptoms

I noticed recently that files were not appearing in my Nautilus file browser. This was especially noticeable when I would compress a folder and the zip would not appear. I would have to manually press f5 in order to see the files. I have a feeling this is something to do with the fact that I am running both Seafile and Dropbox.

Also, when opening a folder in Sublime, I got the following error message which indicated the same issue.

Steps

We just need to add a line to the /etc/sysctl.conf file, specifying the number of inotify watches to provide.

NUM_WATCHES=2140000000
sudo echo "fs.inotify.max_user_watches=$NUM_WATCHES" | sudo tee -a /etc/sysctl.conf

Then to apply the change without needing to reboot, run

sudo sysctl --system

If you change your mind and wish to change the number of watches, be sure to just open the /etc/sysctl.conf in an editor and change the line at the bottom.

References

Last updated: 4th January 2023
First published: 17th June 2021

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch