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 30or 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. – Sparhawk Apr 10 '14 at 01:44sleep 30before thedateline in thesayhiscript had no effect; so maybe that's not the problem. – Daniel Apr 10 '14 at 01:55/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? – Sparhawk Apr 10 '14 at 02:02udevrules act immediately after startup, possibly too early to act as you want. (I'm not sure why this is really, as they should.) As a workaround, you could use an autostart file instead, that activates later, when the X server (e.g. Unity) starts up. It's not ideal, asudevshould work, but it's a workaround. – Sparhawk Apr 10 '14 at 02:12