[TriLUG] How reliable is inotifywait?
Steve Litt via TriLUG
trilug at trilug.org
Tue Mar 12 09:49:20 EDT 2024
Aaron Morrison via TriLUG said on Mon, 11 Mar 2024 19:05:21 -0400
>If I know Steve, he won’t bother or need to see that article. ;-)
>But yes, systemd can do what he wants — he just doesn’t use systemd.
>
>(Hi Steve!)
Hi Aaron, long time no see!
You're right. I'd switch OSes before using systemd. If all OSes had
systemd, I'd give up computers and become a Walmart greeter.
I've got it running no-polling with inotifywait now. I had to overcome
some race conditions inherent in inotifywait and probably a lot of
interrupt driven software. And once I get this thing fully functional,
I'll investigate incron and also watchman to see if they do it even
better.
I'll show you something kind of cute:
==========================================================
prevresults = 500 # Arbitrarily too big
thisresults = 500 # Arbitrarily too big
while (prevresults > 0) or (thisresults > 0):
prevresults = thisresults
thisresults = scan_for_email_files(globls)
==========================================================
The preceding Python code runs when inotifywait terminates due
to a new file being placed in the directory. Once interrupted by an
incoming email, it must go through *two consecutive* no-email email
scans before deciding its done its job until the next inotifywait
interrupt. So if new email comes in while it's processing current
email, it will get that on the next try.
SteveT
Steve Litt
Autumn 2023 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21
More information about the TriLUG
mailing list