This is my rule:
ENV{DEVTYPE}=="usb_device",
ACTION=="remove",
SUBSYSTEM=="usb",
ATTR{idVendor}=="8829",
ATTR{idProduct}=="0010",
RUN+="/bin/mkdir /home/zkd/123"
It doesn't work. But this rule:
ENV{DEVTYPE}=="usb_device",
ACTION=="remove",
SUBSYSTEM=="usb",
RUN+="/bin/mkdir /home/zkd/123"
It works!! And this also works:
ENV{DEVTYPE}=="usb_device",
ACTION=="add",
SUBSYSTEM=="usb",
ATTR{idVendor}=="8829",
ATTR{idProduct}=="0010",
RUN+="/bin/mkdir /home/zkd/123"
So how do I use udev to run a shell script when a USB device is removed? I must recognize the USB device with idProduct and idVendor. Thank for your answer!
Information about removed devices is passed in
ENVrather than inATTRsince there's no longer any device to extract information from.