7

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?

7

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.

| improve this answer | |
4

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

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.