inotify - Erlang OTP application for Linux file monitoring

Version: 0.4.2


Inotify allows to monitor changes to files and directory in the filesystem. It uses Linux inotify functions, hence the name.

This is an OTP application. When started files and directories can be watched by calling inotify:watch/1.

All file notifications are published via a gen_event.


If using as a dependency in another rebar project add this snippet to the projects rebar.config:

  {deps, [
        ... other dependencies ...
        {inotify, ".*", {git, ""}}]}

The application must included in the reltool.config and the applications using this application must have a corresponding entry in their '*.app' files.

This is an OTP application which must be started before it can be used by other applications.

Playing around

If building from git:
 ./rebar compile
You can play around with it by doing this:
 $ export ERL_LIBS=$(pwd) ; erl

 Ref = inotify:watch("/tmp").
Now add a file in "/tmp":
 touch /tmp/test_inotify
You should see some info being printed by inotify. To stop watching:

Real usage

The API is exposed by a single module: inotify.

To be able to associate events each call to inotify:watch/1 returns a unique reference that is also contained in each event.

NOTE: Currently each file or directory can only be monitored once. Each call to inotify:watch/1 with the same path will overwrite the previous.

Users can either write a full blown gen_event handler and add it to inotify_evt via gen_event:add_handler/3 or they can implement the inotify behaviour and call inotify:add_handler/3.

In that case Module:inotify_evt(...) will be called for each event corresponding to 'Tag'.

Generated by EDoc