…with an open minded approach


There is a great linux kernel functionality called “inotify” – which can emmit events on file changes. Its just great, have a look at its home page, I think its one of those linux pearls not much widely known…

Well, the thing is that using inotify, a tool called incron has been made, which is like a cron for file events (instead of time events), and that is really usefull when we want to detect file changes and react accordingly πŸ™‚ very usefull for server scripts πŸ™‚

And so, without further delay, here it goes, the best resume I found so far detailing how to use incron: http://www.howtoforge.com/triggering-commands-on-file-or-directory-changes-with-incron

NOTES: there be dragons…

Inside you incrontabs, you must leave *only* 1 space between the <path> <mask> <cmd>. If you leave 2 or more spaces, then the 2nd (and more) spaces will be considered part of the <mask> or <cmd> and it will fail… I was leaving 2 spaces between <mask> and <cmd>, and incron did not work and in /var/log/syslog there were these messages

incrond[27693]: cannot exec process: No such file or directory

This was because of having 2 spaces… when I corrected to only 1 space, it began working correctly. Keep it in mind, so you dont suffer as much as I did to find it out πŸ™‚


After editing with “incrontab -e”, check that “incrontab -l” shows the rules. If it does not show some rule, then that is because that rule has some error and was not recognized.


To debug what is happening behind the curtains, its usefull to have a “tail -f /var/log/syslog” on another terminal…




4 responses

  1. I started using incron. Awesome tool. Thanks for sharing the link. It is a nice and clear write up.

    March 30, 2014 at 21:24

  2. Pingback: incron, inotifywait | pseudo-scripter

  3. Andy

    Just got caught out with the 1 space bit.. nicely pointed out. thanks

    January 23, 2015 at 11:23

    • Dont really understand it, but ok πŸ™‚

      September 13, 2015 at 23:26

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s