Today I started playing with
[`incron`](http://inotify.aiken.cz/?section=incron&page=about&lang=en).
If you don't know it, it's a nifty tool for launching scripts on file
system events. The configuration is very simple, just some "incrontab"
files in `/etc/incron.d`. Each line in those files has 3 fields:
directory to watch, a comma-separated list of `inotify` events, and the
script and parameters to launch.

I was doing some tests when I started to get this kind of messages in the
logs:

    Mar  1 09:42:30 test-machine incrond[32310]: cannot create watch for system table foo: (2) No such file or directory

I checked and rechecked several times, but the directories I was
watching existed, in the same machine. That is, no obvious mistake. Then
I stopped `incron` and launched it in `strace` and the problem became
evident:

    inotify_add_watch(9, "#", 0)            = -1 ENOENT (No such file or directory)

It happens that `incron` does not support comments in the incrontab files,
so it treats the `#` at the beginning of the line as the path to watch.
Silly thing, if you ask me.

Actually, if you go to its BTS, you'll find bug reports about it[^1][^2]
and some others about its incrontab file parsing[^3][^4]. I'm pretty sure
there must be more around.

So, for now, my "solution" is to count the lines that begin with `#`,
count the lines that report this errors, double check, and if they
coincide, just ignore them. Otherwise, as `incron` stupidly does not
report which file it didn't find, just stop the service and run it under
`strace -ff -e file`.

There are other caveats with `incron`. For instance, `cron` and `at`
launch the commands with `sh` (or the shell you define), but `incron`
doesn't, so you can't easily do any redirections, and any output is
lost, even the stderr. I couldn't get it to do any kind of redirection,
so I ended up doing a wrapper. Lastly, it can't watch more than once
the same dir with the same set of flags.

[^1]: http://bts.aiken.cz/view.php?id=173

[^2]: http://bts.aiken.cz/view.php?id=424

[^3]: http://bts.aiken.cz/view.php?id=539

[^4]: http://bts.aiken.cz/view.php?id=571

