Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a script on device mount in OSX

I want to make a script that automatically backs up my kindle files when I connect it to my macbook pro. Writing the script is well within my ability, but I don't know what's the best way to run a script on mount automatically.

like image 535
heartpunk Avatar asked Feb 15 '10 05:02

heartpunk


1 Answers

You could either use AppleScript and attach a folder action to the /Volumes directory, or you could write a Launch Agent that watches that path.

For the latter, you can refer to Tutorial: Backups with Launchd on MacResearch. The gist of it is that you create a plist configuration file to be interpreted by launchd; then launchd will execute your script when the specified path has changed.

like image 134
benzado Avatar answered Oct 02 '22 13:10

benzado