Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am writing a script which should backup my Documents folder onto a USB stick. I want the script to be executed every time I connect the USB stick. I found a solution here. But it seems like I can't find the folder where to put the rule.

So does anyone know where I could find a udev or rules folder?

share|improve this question
    
Possible duplicate: apple.stackexchange.com/questions/3030/… –  user588 Mar 31 '12 at 14:35
    
possible duplicate of Flash drive autorun script on Mac –  daviesgeek Mar 31 '12 at 21:57

2 Answers 2

up vote 1 down vote accepted

udev doesn't exist on OS X. As an alternative, you can use the diskutil activity command to continuously monitor disks being mounted or ejected. The diskutil man page says

Continuously display system-wide disk manipulation activity as reported by the Disk Arbitration framework until interrupted with a signal (e.g. by typing Control-C). This can be useful to watch system-wide activity of disks coming on-line or being ejected, volumes on disks being mounted or unmounted, volumes being renamed, etc.

Whilst running the above command and plugging in (then removing) my WD Elements USB drive, I get this output, which could be parsed (even though the man page says not to) to find, say, DiskMountApproval and DiskDisappeared to get the volume name and when the disk was added and removed.

***DiskPeek ('disk2') Time=20120331-11:56:22.7716
***DiskPeek ('disk2s1') Time=20120331-11:56:23.0801
***DiskAppeared ('disk2', DAVolumePath = '<null>', DAVolumeKind = '<null>', DAVolumeName = '<null>') Time=20120331-11:56:23.0810
***DiskMountApproval ('disk2s1', DAVolumePath = '<null>', DAVolumeKind = 'hfs', DAVolumeName = 'Elements') Comment=Approving Time=20120331-11:56:23.0820
***DiskAppeared ('disk2s1', DAVolumePath = 'file://localhost/Volumes/Elements/', DAVolumeKind = 'hfs', DAVolumeName = 'Elements') Time=20120331-11:56:23.2574
***DAIdle (no DADiskRef) Time=20120331-11:56:23.2576
***DiskUnmountApproval ('disk2s1', DAVolumePath = 'file://localhost/Volumes/Elements/', DAVolumeKind = 'hfs', DAVolumeName = 'Elements') Comment=Approving Time=20120331-11:56:44.2338
***DiskDescriptionChanged ('disk2s1', DAVolumePath = '<null>') Time=20120331-11:56:44.4515
***DAIdle (no DADiskRef) Time=20120331-11:56:44.4518
***DiskEjectApproval ('disk2') Comment=Approving Time=20120331-11:56:44.4542
***DiskDisappeared ('disk2', DAVolumePath = '<null>', DAVolumeKind = '<null>', DAVolumeName = '<null>') Time=20120331-11:56:50.1964
***DiskDisappeared ('disk2s1', DAVolumePath = '<null>', DAVolumeKind = 'hfs', DAVolumeName = 'Elements') Time=20120331-11:56:50.1970
***DAIdle (no DADiskRef) Time=20120331-11:56:50.1972
share|improve this answer

udev is Linux specific, so you won't find that in OS X.

You'll need to look for alternative ways of writing your script, e.g. using diskutil.

share|improve this answer
1  
Thank you :) This is exactly what I need.. –  rojcyk Mar 31 '12 at 11:11

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.