I've made a little udev rule that launch a script that make an archive of my ~/Documents directory.That do the job, but when I read the log file, it seems that the archive script is executed 3 times when I plug my key.Here's my rule:ACTION==add, SUBSYSTEMS==usb, DRIVERS==usb, ATTRS{idVendor}==0951, ATTRS{idProduct}==1642, RUN+=/bin/sh /root/auto-archive Here's my script:#! /bin/shsleep 5# test if awesome is runningif ps aux | grep -v launch | grep -v grep | grep awesomethen    echo awesome is running >> /home/purplepsycho/logelse    # echo awesome not running another guy must be logged    exitfiif mount | grep /media/usbthen    echo /media/usb already mounted >> /home/purplepsycho/log    exitfi# mount keyecho mounting... >> /home/purplepsycho/log/usr/bin/sudo -u purplepsycho mount /media/usb# test if mount have been succesfulif [ $? -ne 0 ]then    echo mount failed >> /home/purplepsycho/log    exitfi# archive dirARC_DIR=/media/usb/archive# make directorymkdir -p $ARC_DIR# archive nameNAME=$(date +archive-%Y-%m-%d.tgz)# test if an archive already exists for todayif [ -f $ARC_DIR/$NAME ] then    echo archive file already exists for today >> /home/purplepsycho/log    exitfi# initialize log fileecho $NAME > $ARC_DIR/files.txt# make the archivetar -zcvf $ARC_DIR/$NAME /home/purplepsycho/Documents/* >> $ARC_DIR/files.txtAny idea? Thanks.---Edit after Sparhawk comment---I run udevadm on my key:udevadm info -a -p $(udevadm info -q path -n /dev/sbd)Which gave:looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb':  KERNEL==sdb  SUBSYSTEM==block  DRIVER==looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host4/target4:0:0/4:0:0:0':  KERNELS==4:0:0:0  SUBSYSTEMS==scsi  DRIVERS==sdlooking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host4/target4:0:0':  KERNELS==target4:0:0  SUBSYSTEMS==scsi  DRIVERS==looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/host4':  KERNELS==host4  SUBSYSTEMS==scsi  DRIVERS==looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0':  KERNELS==1-1:1.0  SUBSYSTEMS==usb  DRIVERS==usb-storagelooking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-1':  KERNELS==1-1  SUBSYSTEMS==usb  DRIVERS==usb  ATTRS{idVendor}==0951  ATTRS{idProduct}==1642looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1':  KERNELS==usb1  SUBSYSTEMS==usb  DRIVERS==usb  ATTRS{idVendor}==1d6b  ATTRS{idProduct}==0002looking at parent device '/devices/pci0000:00/0000:00:1d.7':  KERNELS==0000:00:1d.7  SUBSYSTEMS==pci  DRIVERS==ehci-pci  ATTRS{irq}==23looking at parent device '/devices/pci0000:00':  KERNELS==pci0000:00  SUBSYSTEMS==  DRIVERS==I tried to write rules only based on:  KERNELS==1-1  SUBSYSTEMS==usb  DRIVERS==usb  ATTRS{idVendor}==0951  ATTRS{idProduct}==1642and  KERNELS==usb1  SUBSYSTEMS==usb  DRIVERS==usb  ATTRS{idVendor}==1d6b  ATTRS{idProduct}==0002The result is the same: script is called multiple times...
Why is my udev rule executed three times
udev
The problem comes from your rule: you only try to match a parent of your device, and not the device itself... see http://reactivated.net/writing_udev_rules.html#sysfstree for details: you must match the device (KERNEL=, SUBSYSTEM=, ATTR= ...),and one of its parent (KERNELS=, SUBSYSTEMS=, ATTRS= ...) (note the 'S' at the end on fields).The corrected rule is:ACTION==add, KERNEL==sdb1, SUBSYSTEM==block, ATTRS{vendor}==Kingston, ATTRS{model}==DT 101 G2, RUN+=/bin/sh /root/auto-archive