I'm trying to run a script when a device is connected. My udev and systemd files are loaded and triggered, but will only launch the script a single time. If I disconnect and reconnect the device, the script no longer launches. I have found that reloading systemctl at the end of my script will fix this issue (this method only works for 'user' systemd services). In previous version of Ubuntu, I was able to simply use udev with systemd, and it worked every time. It also didn't matter if I used either 'user' or 'system' service files. They both worked, which also allowed me to run commands as root.

I don't believe my script is the issue, as a simple file launch or notify-send command will only work after reloading systemctl (or if I reboot).

How can I use systemd where I don't have to constantly reload systemctl for it to work? Also if possible, how can I regain the systemd/system usage so I can run scripts as root?

Edit: I am using the desktop version of Ubuntu 20.04.

I have used the command systemctl status and it showed that I had a failed service (wasn't my custom service file). I disabled the service and reloaded. No more failed services, but my original problem persists.

  • 2
    you are missing , ENV{SYSTEMD_WANTS}+="my.service" (or SYSTEMD_USER_WANTS for user services)
    – user986805
    May 13, 2020 at 17:00

1 Answer 1


Answer by OP, removed from the question:

Fixed: I added ENV{SYSTEMD_USER_WANTS}+="myfile.service" into my udev file, and it appears to have fixed the issue. Thanks bac0n for the suggestion.

Also, thanks to everyone else who volunteered their time.

My udev entry:

ACTION=="add", ATTRS{product}=="DTK-2100", ATTRS{idProduct}=="00cc", ATTRS{idVendor}=="056a", TAG+="systemd"

my systemd entry:



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .