I use inotifywait
for event trigger which put file.
When many files are watched by inotifywait
, when max_user_watches
is exceeded, the following error occurs.
Terminating since out of inotify watches.#012Consider increasing /proc/sys/fs/inotify/max_user_watches
It is necessary to tune /proc/sys/fs/inotify/max_user_watches
, but is it possible to check the current file watch number?
Is there a way to check like file-nr in file descriptor?
Best Answer
I cobbled together this little script based on @mosvy's answer. Since the initial conception, it has since seen quite a few improvements (stability on older systems, total count, speed). On most normal machines, running it should take a less than 100 ms. Even though it was much faster than the other alternatives when I made it initially, Simon Matter added some speed enhancements for heavily loaded Big Iron Linux (hundreds of cores) that sped it up immensely, taking it down from ten minutes (!) to 15 seconds.