Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently writing my thesis at a big company, with an even bigger corporate firewall. So I've to save my work on an USB flash drive. Now I'm searching for a backup solution for that flash drive and don't want to do this manually. Does somebody know how to run a program / bash file when this specific USB device id connects to my computer so I can automate the rest of the process?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Create a LaunchDaemon (if you want the script to run independently of who's logged in) or LaunchAgent (if you want it to run inside the current user's session), with the StartOnMount key set to true. The script will be run anytime any volume mounts, so you'll need to start the script with something to detect your particular drive -- it could check by name (i.e. look for "/Volumes/My Backup Drive"), by a contained file (look for /Volumes/*/.backupTarget), or whatever. If you want some sort of hardware ID, your best bet is probably the ioreg command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.