Re: udev rules 2 times exec script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



If the command shares any resources, and name “autobackup” suggests it does, it should include some mechanism that prevents concurrent execution if another instance is already running. Otherwise, even if a single match happens, multiple instances of the script may be executed. For USB devices that may be a tiny power interruption during insertion, causing it to be detected, removed, detected again:

insertion - - - removal - - - insertion - - - - - - -
  |-- script ---------------------------------------> \_ two instances
                                |-- script ---------> /  of the code

It should be either of those:
  |-- script ------------------------------------------------->
                                |--- BAIL OUT! -|
or
  |-- script --------------------------------- end|
                                |-- WAIT .......... script --->

SUBSYSTEM=="block", ACTION=="add", ATTRS{idVendor}=="058f",
ATTRS{idProduct}=="6387", SYMLINK+="external%n",
RUN+="/usr/local/bin/autobackup.sh"

This works well, buth exec 2 times the script...

Jun 12 13:53:09 archlaptop autobackup.sh: BEGIN SCRIPT
Jun 12 13:53:13 archlaptop autobackup.sh: BEGIN SCRIPT
  Because there are two matches for that pattern:
 - //devices/platform/…/target0:0:0/0:0:0:0/block/sda
 - //devices/platform/…/target0:0:0/0:0:0:0/block/sda/sda1
Both of them have SUBSYSTEM=="block", ACTION=="add", ATTRS{idVendor}=="058f" and ATTRS{idProduct}=="6387".

If add ENV{DEVTYPE}=="usb_device" and change the
SUBSYSTEM=="usb_device" , when plug usb, udev does nothing ...
  Because there is nothing that matches SUBSYSTEM=="usb_device".

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux