I'm having trouble with udev rules not running. Here's an example:
I have a rule /etc/udev/rules.d/99-test.rules
which contains:
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", RUN+="/sayhi"
And sayhi
just has:
#!/bin/bash
date +"%Y-%m-%d %H:%M:%S,%3N" >> /saidhi
This being an Intel machine, I obviously have many vendor 0x8086 PCI devices:
root@imtrobot:~# lspci -n |grep 8086
00:00.0 0600: 8086:2770 (rev 02)
00:02.0 0300: 8086:2772 (rev 02)
00:1d.0 0c03: 8086:27c8 (rev 01)
[ etc. 12 lines total ]
And yet, when I boot, /saidhi
will either not be created at all, or will have 1 or 2 date lines in it.
If, after booting, I run udevadm trigger --action=add --subsystem-match=pci
then /saidhi
will get exactly the right number of dates added to it.
Why doesn't this work during the boot process?
sleep 30
or how long is appropriate. Or you could (possibly?) poll to see if the directory exists with[ -e / ]
. I'm not sure if you can look at/
, so maybe[ -e /tmp ]
instead.sleep 30
before thedate
line in thesayhi
script had no effect; so maybe that's not the problem./
isn't mounted, then the udev script would never be called at all. Do you boot into x? Perhaps it'd be better to run scripts when the GUI loads up?