I would like to launch a script via a udev rule:
The problem is test.sh takes a long time to run (it is a backup script), and HAL does not mount the partitions correctly if test.sh takes too much time.
SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNEL=="sd?1", RUN+="/home/user/bin/test.sh"
This problem is discussed here: /usr/share/doc/udev/writing_udev_rules/index.html
How do you write a script that detaches itself?
[the script] must not run for any extended period of time, because udev is effectively paused while these programs are running. One workaround for this limitation is to make sure your program immediately detaches itself.
I've tried modifying the udev rule by putting an ampersand at the end of the command
This does not work.
SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNEL=="sd?1", RUN+="/home/user/bin/test.sh &"
So here is my crude workaround:
This works, but it feels wrong. Is there a more elegant way to do this?
<...insert backup commands here...>