Sample Header Ad - 728x90

How to monitor a directory for changes across reboots?

0 votes
0 answers
318 views
I'm searching for a tool that will allow me to run a program for every change in a directory, but is guaranteed to run exactly once per change even across system reboots. For the purposes of this question, (inode, mtime, size) is sufficient to detect a "change". Does something like this already exist? Things that are insufficient: - [stat](https://linux.die.net/man/1/stat) . I could hand-roll a script that stored a stat database, and run it from cron, but ideally I'd like something that tied into inotify while it was running to instantly detect changes. - [inotifywait](https://linux.die.net/man/1/inotifywait) . Obviously, my inotify watches would be destroyed on reboot. I'm looking for something that could (for example) be run by cron every 5 minutes and still detect every change only once. - [logstash](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html) . I know that logstash can monitor a directory of files in the manner that I'm looking for, but it's designed to handle log files. It may be possible to hack logstash to do what I want, but I couldn't figure out how. Does anything like this exist, or am I out of luck?
Asked by Ryan Patterson (101 rep)
Feb 9, 2021, 05:27 AM