Start systemctl service on user login
Solution 1
I think you have to enable
the service first:
systemctl --user enable voodoo.service
Created symlink /home/andreatsh/.config/systemd/user/default.target.wants/voodoo.service → /home/andreatsh/.local/share/systemd/user/voodoo.service
As you can see, this simply create a symlink in the appropriate folder. Then I run:
systemctl --user restart voodoo.service
and the service worked fine.
Solution 2
Two, actually. This is the far more probable one.
Ubuntu 15 switched to systemd for system-wide service management. But per-user service management was still the domain of upstart, and this was still the case in 16.04.
So naturally systemctl
isn't going to find a per-user instance of systemd
to talk to. Note that systemctl
did not say that it didn't recognize the service unit file. It said that it could not connect to the "bus" through which it talks to the per-user instance of systemd
.
Further reading
- https://askubuntu.com/a/613814/43344
- https://askubuntu.com/a/780747/43344
- https://askubuntu.com/a/844502/43344
- https://unix.stackexchange.com/a/194208/5132
Related videos on Youtube
daisy
Updated on September 18, 2022Comments
-
daisy over 1 year
I'm trying to create a service that runs at user login.
As a non-root user, I've created a file:
> cat ~/.local/share/systemd/user/voodoo.service [Unit] Description=User service test [Service] RemainAfterExit=yes Type=simple ExecStart=/bin/bash -c "touch /tmp/ok123" [Install] WantedBy=default.target
But, systemctl does not recognize it,
> systemctl --user restart voodoo.service Failed to connect to bus: No such file or directory
Any ideas?