0

I have a systemd service that starts from a udev rule:

[Unit]
Description=Open DSLR camera device

[Service]
ExecStart=/bin/sh -c "/tmp/test.sh"

/tmp/test.sh doesn't do much yet:

#!/bin/sh
echo "qwer" >> /tmp/dslr-udev-test.txt

I don't think the udev rule is relevant (it triggers on connecting my DSLR camera on usb). Here it is anyway:

SUBSYSTEM=="usb", ACTION=="add", ATTR{product}=="Canon Digital Camera", TAG+="systemd", ENV{SYSTEMD_WANTS}="dslr-device.service"

After running sudo systemctl daemon-reload and turning the camera on, the file /tmp/dslr-udev-test.txt shows new content. But only once! Turning the camera off and on again shows no new content.

After running sudo systemctl daemon-reload again, the file shows new content once upon turning on the camera, then no more upon further camera restarts.

What is preventing the service's ExecStart from running more than once after daemon-reload?

3
  • Have you tried troubleshooting the udev part using udevadm monitor? – Martin Konrad Jun 24 '20 at 1:03
  • Does sudo systemctl daemon-reload && sudo systemctl start dslr.service add a line to your file? – Martin Konrad Jun 24 '20 at 1:05
  • What is the output of systemctl status dslr-device.service after the first execution? – Hauke Laging Jun 24 '20 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.