Monitoring and taking action when drives mount and unmount

jhuls
Contributor III

I'm looking at some scenarios where it would be nice to have a script ran when certain network or local drives are mounted or unmounted. Has anyone done something like this? If so, how? I'm not quite sure where to start.

1 REPLY 1

mm2270
Legendary Contributor III

One place to start would be to look at a LaunchAgent (these run in the user space) that would use the StartOnMount key. This triggers the LaunchAgent to run whatever script or processes you specify whenever the OS sees a share get mounted.