1

I have this inotifywait command watching a log file, once triggered runs some other code which takes 0.2s to complete. This works fine when the log is not being massively updated, but when there's more than a few new entries, the code is being repeated over and over unnecessarily.

What I'm trying to achieve is, as the title states, to limit the number of inotify triggers to a maximum of (specifically to this case, given the .2s execution time) 5 times per second.

I've tried to search in the inotify documentation but there doesn't seem to be any function doing such, so I guess I'm stuck working something out within Bash itself.

How would you suggest approaching this? Would using the internal $SECOND tied to a while loop with a counter be a viable option?

Thanks

  • On the assumption that you're using monitor -m mode, what about single shot mode, run your script, then re-register the notify? – Jeff Schaller Jan 17 '16 at 14:46
  • that did the trick, but aren't some extra milliseconds missing over the normal code? inotify probably takes another 150-250ms to set up watches I guess. – nxet Jan 17 '16 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.