How can I constantly monitor (small) file for changes?
Eg. when file is updated (action from web application), a script is executed (if not already running).
Right now, I do it every minute using cron, but this has delay up to one minute. I'd like to take the action immediately after the file is changed.
Maybe I need to write some low level process running in the background, once the server is started?
The reason I want to do it is to separate web application from root actions (performed on demand, once when file is updated).
Best Answer
incrond (inotify cron daemon) behaves like cron but uses inotify as the triggering mechanism. This guide has some pretty comprehensive examples.
An example incron entry for the case you described might be: