I have a task to create a way of monitoring a folder and files running on a MacOS 10.11 machine.
Basically what I want to accomplish is each time a new file is added to the folder send a notification to a monitoring URL and if after 30 minutes no files are added it will trigger an alert.
I am new to Mac OS programming but I have been tasked with this project and just looking for some suggestions on how to accomplish this
Best Answer
I assume you intend to build something on your own. Things to look into here are
launchd
: Allows programs/scripts to be run based on certain conditions. Of special interest for you is probably theWatchPaths
parameter which allows to watch a path/directory for changes and triggers a program/script if necessary. There are race conditions involved here, but for your case you probably can catch them easily. The full format for launchd configuration files is available withman launchd.plist
On second thought, I would ignore the
WatchPaths
part completely. Just uselaunchd
to run a shell script every 30 minutes (or whatever is appropriate) which, if no new file has arrived since when-ever, sends a notification to wherever.