我下载并构建了一个应用程序,其中包含用于在连接特定硬件时启动应用程序的 udev 规则。根据日志,该应用程序似乎作为 udev 规则的一部分成功启动,但它似乎没有持续存在,因为我永远找不到正在运行的进程,而且它也没有。
项目: http://sourceforge.net/projects/mochad/
Udev 规则:
/etc/udev/rules.d/91-usb-x10-controllers.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="0bc7", ATTR{idProduct}=="0001", RUN+="/usr/local/bin/mochad"
SUBSYSTEM=="usb", ATTR{idVendor}=="0bc7", ATTR{idProduct}=="0002", RUN+="/usr/local/bin/mochad"
系统日志片段:
Jan 23 11:36:22 home systemd-udevd[23442]: starting '/usr/local/bin/mochad'
Jan 23 11:36:22 home mochad[23442]: starting
Jan 23 11:36:22 home systemd-udevd[23439]: Process '/usr/local/bin/mochad' succeeded.
Jan 23 11:36:22 home systemd-udevd[23439]: passed device to netlink monitor 0x54d28fe0
Jan 23 11:36:22 home systemd-udevd[23439]: seq 1024 processed
Jan 23 11:36:22 home systemd-udevd[135]: passed 300 byte device to netlink monitor 0x54d24bb8
Jan 23 11:36:22 home systemd-udevd[23439]: seq 1025 running
Jan 23 11:36:22 home systemd-udevd[23439]: IMPORT builtin 'usb_id' /lib/udev/rules.d/40-libgphoto2-6.rules:9
Jan 23 11:36:22 home systemd-udevd[23439]: unable to access usb_interface device of '/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0'
Jan 23 11:36:22 home systemd-udevd[23439]: IMPORT builtin 'usb_id' returned non-zero
Jan 23 11:36:22 home systemd-udevd[23439]: IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:15
Jan 23 11:36:22 home systemd-udevd[23439]: IMPORT builtin skip 'usb_id' /lib/udev/rules.d/56-hpmud.rules:10
Jan 23 11:36:22 home mochad[23443]: Found CM15A
Jan 23 11:36:22 home systemd-udevd[23439]: RUN 'kmod load $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5
Jan 23 11:36:22 home mochad[23443]: In endpoint 0x81, Out endpoint 0x02
Jan 23 11:36:22 home systemd-udevd[23439]: created db file '/run/udev/data/+usb:1-1.2:1.0' for '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0'
Jan 23 11:36:22 home systemd-udevd[23439]: Execute 'load' 'usb:v0BC7p0001d0100dc00dsc00dp00ic00isc00ip00in00'
Jan 23 11:36:22 home systemd-udevd[23439]: No module matches 'usb:v0BC7p0001d0100dc00dsc00dp00ic00isc00ip00in00'
Jan 23 11:36:22 home systemd-udevd[23439]: passed device to netlink monitor 0x54d28fe0
Jan 23 11:36:22 home systemd-udevd[23439]: seq 1025 processed
Jan 23 11:36:22 home systemd-udevd[135]: cleanup idle workers
Jan 23 11:36:22 home systemd-udevd[23439]: Unload module index
Jan 23 11:36:22 home systemd-udevd[23439]: Unloaded link configuration context.
Jan 23 11:36:22 home systemd-udevd[135]: worker [23439] exited
但是,在我手动启动它之前,我没有要连接的正在运行的进程(它必须以 sudo 权限运行)。udev 规则有问题吗?还是有其他原因阻止了它正常工作?
Ubuntu 15.10
答案1
虽然这不是一个合适的解决方案,但我最终解决了这个问题,通过每分钟运行一个 cron 作业来检查应用程序是否正在运行,如果没有,则启动它。