Can you monitor a folder for changes?
Question
Let's say I have a folder that is located in "/tmp".
Let's say it is called myfolder "/tmp/myfolder" and I would like to protect this folder or I would like to be notified if changes are made to this folder.
I heard it should be possible with "syslog", how it works I don't know
Solution
We can monitor folders in at least three ways:
- Using AppleScript Folder Actions, which can monitor when files are added or removed form a folder, or when the folder window is opened, closed, or moved int he Finder. see Folder Actions Reference.
- Using a launchd launch agent, which can launch a unix script or script application when the file system changes at a particular path. See Launch Daemons and Agents.
- Create an AppleScript application that uses AppleScriptObjC to receive notifications for file system changes. I can add an example of that if you think it's necessary, though I'd recommend using one of the others for most cases.
I suppose something could be done using syslog, but it seems like a lot more work than the approaches I mentioned.
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange