20

According to Wikipedia,

inotify is a Linux kernel subsystem which notices changes to the file system. It replaced the previous dnotify.

Programs that sync files (such as crashplan, dropbox, git) recomend in user guides that the user increase max_user_watches (1, 2, 3).

From what I understand about inotify, the OS is "told" that a file has been changed, instead of requiring the OS to "go looking" for changes.

I assume that there is an "inotify" file created in every directory. Is this correct? Is there a way to interact with inotify from the command line?

Resources
Why are inotify events different on an NFS mount?
Inotifywait for large number of files in a directory

1
  • You probably won't find the answers to your questions this way (at least, not easily) but you should run grep --exclude=arch -r inotify in the Linux kernel sources.
    – user26112
    Jul 25, 2013 at 2:07

1 Answer 1

26

Inotify is an internal kernel facility. There is no “inotify file”. There are dedicated system calls inotify_init, inotify_add_watch and inotify_rm_watch that allow processes to register themselves to be notified when certain filesystem events happen. When the event happens, the process receives a description of the event through the file descriptor returned by inotify_init.

The OS isn't “told” that a file has been changed: it knows, because it's doing the changing. It's the application that's told that a file has been changed instead of having to go looking.

The program inotifywait provides a simple way to use inotify from the command line.

1
  • The inotify interface MAY be offered by filesystems. Not all do. Pseudo (generated programmatically) filesystems like /tmp, /proc,. ... don't.
    – waltinator
    Jul 30 at 22:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .