Frage

I am trying to write a udev rule for USB drive plugin. I want to first mount it to /media and then run the script at /usr/local/bin/script.sh. When I insert the USB, it doesn't even mount the device with this rule. However, If I manually type the part in RUN into terminal, It mounts and executes script.

The rule file says:

ACTION=="add", KERNEL=="sd[a-z]*", RUN+="/bin/mount -t auto /dev/%k /media/ && /usr/local/bin/script.sh"

Is this the right way to execute two commands in RUN section of the rule?

War es hilfreich?

Lösung

/bin/mount doesn't take && as an argument. If you want a shell chain to be executed then you must pass it to a shell.

RUN+="/bin/sh -c '...'"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top