udev rule to run a script when inserting a USB

0

I try to create a udev rule to run a script when a USB stick is inserted.

In /etc/udev/rules.d/ I created the file setupMyApp.rules with the following line:

ACTION=="add",KERNEL=="sd[a-z]?",SUBSYSTEMS=="usb",RUN+="/root/setupMyApp.sh"

In /root/setupMyApp.sh I have the following lines to check that it works correctly:

#!/bin/bash
echo "['date'] Se ha insertado un dispositivo USB" >> pruebasUSB.txt

After creating these two files and every time I modified the rule udev I have restarted the service with these lines:

# service udev restart
# /etc/init.d/udev restart

But there is no way to make it work. What can I try or do to find the error?

Thanks in advance to everyone!

    
asked by Jonathan 14.09.2018 в 13:41
source

0 answers