Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently facing a problem on a linux box where as root I have commands returning error because inotify watch limit has been reached.

# tail -f /var/log/messages
tail: cannot watch '/var/log/messages': No space left on device
# inotifywatch -v /var/log/messages
Establishing watches...
Failed to watch /var/log/messages; upper limit on inotify watches reached!
Please increase the amount of inotify watches allowed per user via '/proc/sys/fs/inotify/max_user_watches'.` 

I googled a bit and every solution I found is to increase the limit with:

sudo sysctl fs.inotify.max_user_watches=<some random high number>

But I was unable to find any information of the consequences of raising that value. I guess the default kernel value was set for a reason but it seems to be inadequate for particular usages. (e.g., when using Dropbox with a large number of folder, or software that monitors a lot of files)

So here are my questions:

  • Is it safe to raise that value and what would be the consequences of a too high value?
  • Is there a way to find out what are the currently set watches and which process set them to be able to determine if the reached limit is not caused by a faulty software?
share|improve this question
up vote 102 down vote accepted

Is it safe to raise that value and what would be the consequences of a too high value?

Yes, it's safe to raise that value and below are the possible costs [source]:

  • Each used inotify watch takes up 540 bytes (32-bit system), or 1 kB (double - on 64-bit) [sources: 1, 2]
  • This comes out of kernel memory, which is unswappable.
  • Assuming you set the max at 524288 and all were used (improbable), you'd be using approximately 256MB/512MB of 32-bit/64-bit kernel memory.
    • Note that your application will also use additional memory to keep track of the inotify handles, file/directory paths, etc. -- how much depends on its design.

To check the max number of inotify watches:

cat /proc/sys/fs/inotify/max_user_watches

To set max number of inotify watches


  • Run sudo sysctl fs.inotify.max_user_watches= with your preferred value at the end.


  • Replace the value within the /proc/sys/fs/inotify/max_user_watches file with your own, i.e echo 524288 | sudo tee -a /proc/sys/fs/inotify/max_user_watches.

Check to see if the max number of inotify watches have been reached:

Use tail with the -f (follow) option on any old file, e.g. tail -f /var/log/dmesg: - If all is well, it will show the last 10 lines and pause; abort with Ctrl-C - If you are out of watches, it will fail with this somewhat cryptic error:

tail: cannot watch '/var/log/dmsg': No space left on device

To see what's using up inotify watches

for foo in /proc/*/fd/*; do readlink -f $foo; done |grep inotify |cut -d/ -f3 |xargs -I '{}' -- ps --no-headers -o '%p %U %c' -p '{}' |uniq -c |sort -nr

The first column indicates used amount and the second shows the PID of that process [sources: 1, 2].

share|improve this answer
I guess very few codes need the values higher than the default Dropbox may require a higher limit, depending on how many files you have. Iv'e raised mine with no issues. in fact, the dropbox notification (that occurs when it reaches its limit) explicitly tells you to raise it. – Falmarri May 25 '11 at 20:55
Isn't there also a dnotify that works the same, but on directories? Maybe consolidate multiple files you are inotifying into a single directory? – LawrenceC Jun 16 '11 at 13:36
@ultrasawblade: am not familiar enough with the technology to give you a decent answer – Tshepang Jun 20 '11 at 8:55
@ultrasawblade- inotify replaced dnotify. dnotify was slow and buggy. inotify can be used on directories, and a directory will be "changed" when one of the files in that directory (one level deep) is modified. Directories are just files anyway. – tjameson Jul 10 '11 at 5:14
"Permanently: Replace the value within the /proc/sys/fs/inotify/max_user_watches" <-- this is incorrect. To make this permanent you need to change /etc/sysctl.conf – Merc May 7 at 4:38

I can't add this as a comment to the above answer, so in favor of all who encounters this I'd like to mention that:

In order to make the change permanent, unlike the above answer, you may need to add fs.inotify.max_user_watches=$<INSERT-VALUE> to file /etc/sysctl.conf as shown below:

$: sudo echo "fs.inotify.max_user_watches=$<INSERT-VALUE>" >> /etc/sysctl.conf

To make the changes take effect without rebooting, run:

$: sudo sysctl -p /etc/sysctl.conf
share|improve this answer
Accepted answer does not work as a permanent fix. This one solved the problem – mandeep_m91 Nov 13 '15 at 9:31
Also note that $<INSTERT-VALUE> should become 524288 and not $<5242888> – Frozenfire Feb 16 at 12:31
This is apparently outdated, they're now files in the /etc/sysctl.d folder (at least on Arch) – MightyPork Jun 16 at 22:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.