[mdlug] How reliable is inotifywait?
Mark Montague
markmont at umich.edu
Sun Mar 10 23:07:23 EDT 2024
Hi, Steve,
inotifywait is very reliable except in edge cases -- read the inotify(7)
man page for details.
You may want to look at Watchman ( https://facebook.github.io/watchman/
). Watchman attempts to be as conservative as possible, and if it
thinks events might have been dropped, it re-scans the
directory/directories to be sure. However, Watchman has separate service
and client parts as well as more dependencies, so it may or may not be
suitable for your use case.
Personally, I think inotifywait is suitable in most cases, and
preferable in many cases, particularly if you increase the Linux inotify
limits (
https://facebook.github.io/watchman/docs/install#linux-inotify-limits )
--
Mark Montague
On 2024-03-10 18:08, Steve Litt wrote:
> Hi all,
>
> The inotifywait program waits until a specific file event happens in a
> specific directory or file, and then terminates. So it enables
> file-driven event driven programs.
>
> I'd like to wake up the instant a file appears in a directory.
> Something like the following:
>
> inotifywait -e create -e moved_to -t 30 /tmp/pager
>
> The preceding waits 30 seconds, except if a file is created in or moved
> to /tmp/pager, it quits waiting and terminates immediately.
>
> I use it to combine polling with an event driven, so if for some reason
> the event (moved_to or create) doesn't quit and terminate immediately,
> it will still quit and terminate at the end of 30 seconds.
>
> I can significantly simplify my program if I changed -t 30 to t -1,
> where -1 stands for "forever". False positives aren't a problem: They
> would just start another cycle. But false negatives, where a file is
> created or moved into /tmp/pager but fails to quit and terminate, would
> really mess me up in this particular situation.
>
> So what do you think, is inotifywait reliable?
>
> Thanks,
>
> SteveT
>
> Steve Litt
>
> Autumn 2023 featured book: Rapid Learning for the 21st Century
> http://www.troubleshooters.com/rl21
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
More information about the mdlug
mailing list