0

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

1
  • I think you need to tell us what you are trying to achieve, as this could be an XY problem. (i.e. there may be another method of obtaining your goal than the method you're trying.) Why not just restrict access, instead of checking afterwards?
    – benwiggy
    Mar 19 at 22:18
3

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.

1
  • There is also a "Stay Open" script that can be used. The advantage is that the script is not confined to a single folder, so if you want a script to monitor a temporary job folder for a few minutes/hours, using this method would allow you to choose the folder each time you run the script! apple.stackexchange.com/questions/302963/… Aug 29 at 21:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .