I would like to launch a script via a udev rule:
Code:
cat /etc/udev/rules.d/81-local.rules
SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNEL=="sd?1", RUN+="/home/user/bin/test.sh"
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.
This problem is discussed here: /usr/share/doc/udev/writing_udev_rules/index.html
[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.
How do you write a script that detaches itself?
I've tried modifying the udev rule by putting an ampersand at the end of the command
Code:
SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNEL=="sd?1", RUN+="/home/user/bin/test.sh &"
This does not work.
So here is my crude workaround:
Code:
cat test.sh
#!/bin/sh
test2.sh &
cat test2.sh
#!/bin/sh
<...insert backup commands here...>
This works, but it feels wrong. Is there a more elegant way to do this?
Bookmarks