I'm trying to set a simple script to run whenever a USB storage device is being plugged to the computer. For that task I have a 100-usb.rules file in /etc/udev/rules.d which has a very generic rule:
ACTION=="add", RUN+="/usr/local/auto-update.sh"
I expect that whenever I plug anything to the computer that script will trigger. The reason the rule is so generic is because doesn't matter what kind of rule I tried the script just NEVER being run.
Now the /user/local/auto-update.sh script has a very simple command:
#!/bin/bash
mkdir /tmp/testfolder
I've made sure to give execute rights to the script with
sudo chmod +x /usr/local/auto-update.sh
after running the command ls -l /usr/local/auto-update.sh I get the permissions
-rwxr-xr-x
The weird thing is that if I alter my rule to look something like
ACTION=="add", RUN+="/bin/mkdir /tmp/folder1"
Then it is actually going ahead and creating that folder.
I really am lost here... I have NO clue why it's not working!
ls -l /usr/local/auto-update.sh. You have only given execute rights to the owner of the file, not everyone. – terdon Sep 13 '15 at 12:37/bin/bash /usr/local/auto-update.shwill probably work – kos Sep 13 '15 at 12:42RUN+="/usr/local/auto-update.sh 2>/tmp/error". I'm not sure if that will work but it might give us some debugging information. – terdon Sep 13 '15 at 12:55bashpath became mandatory, but it doesn't reference any source. I guess the command is not interpreted by a shell, but if it is doing what terdon suggested definetly could give an insight – kos Sep 13 '15 at 12:58/tmp/errorfile is never being created. – kfirba Sep 13 '15 at 13:00/tmp/testfoldercreated? – terdon Sep 13 '15 at 13:03/tmpand it still works, could you delete this question? If it's not reproducible, it's unlikely to help anyone else. – terdon Sep 13 '15 at 13:06100-usb.rulesto99-usb.rules– user.dz Sep 19 '15 at 10:25