2

I am running inotifywait (inotify-tools-3.14-1) in the daemon mode, however, it gave the following error and no watches are established. Also, since it is within the while loop, there were many inotifywait daemon processes created.

I have no such problem if running with --monitor instead of --daemon. Can someone help fixing it? Thanks a lot.

"Couldn't initialize inotify. Are you running Linux 2.6.13 or later, and was the CONFIG_INOTIFY option enabled when your kernel was compiled? If so, something mysterious has gone wrong. Please e-mail radu.voicilas@gmail.com and mention that you saw this message."

Below is the code:

while true  # run indefinitely
do
  inotifywait --daemon --outfile /tmp/daemon.log --event close_write --format '%w%f %e %T' --timefmt '%F %T' $folder |  while read eventInfo
     do
        call_another_fun $eventInfo
        break
     done
   done
jlp
  • 1,656
  • 6
  • 33
  • 48

3 Answers3

4

When there are too many inotify processes running in background, I also get this "Couldn't initialize inotify..." error message. A pkill inotify solved this.

Friedrich
  • 106
  • 1
  • 2
3

You should increase the maximum amount of inotify instances.

sudo sysctl fs.inotify.max_user_instances=2048

On my Desktop System the default of 128 Instances was to low for a few file-browsers, IDEs and electron apps. All of them have multiple inotify instances.

To make this permanent, add this line into /etc/sysctl.conf

fs.inotify.max_user_instances=2048
0

Uninstalling

apt-get remove inotify-tools

Then reinstalling

apt-get install inotify-tools

resolved it for me. Between uninstalling and reinstalling I happened to have also run sudo apt autoremove but I doubt that it was part of the solution.

David
  • 895
  • 8
  • 12