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./bin/bash /usr/local/auto-update.sh
will probably workRUN+="/usr/local/auto-update.sh 2>/tmp/error"
. I'm not sure if that will work but it might give us some debugging information.