Running user-level systemd service in Leap?

I’m playing around with systemd, trying to get it to be the kickoff point for some services that I want run as a non-root user, but I can’t seem to get it to work. Here’s what I’ve tried, with my service file under ~/.config/systemd/user:


$ systemctl --user enable <my-service>
Failed to get D-Bus connection: No such file or directory

Okay, let’s try to start a local d-bus:


$ dbus-launch
$ export DBUS_SESSION_BUS_ADDRESS=<address given by dbus-launch>
$ export DBUS_SESSION_BUS_PID=<pid given by dbus-launch>
$ systemctl --user enable <my-service>
Failed to execute operation: Process org.freedesktop.systemd1 exited with status 1

Okay, let’s ensure systemd is running for this user:


$ systemd --user
Failed to create root cgroup hierarchy: Permission denied
Failed to allocate manager object: Permission denied

Anyone know how to get systemd and d-bus user sessions up and running?

Hi
What are you trying to run? Can you post the service file your using? Where are your saving the user service?

Normally you would just have a User=%i and Group=users and called somename@.service.

A common sense to creating a systemd service for a Beginner…

  1. Look for an existing service that does something close to the new service you want to create
    The default existing systemd Unit files are located in the /system and /user subfolders at
/usr/lib/systemd/
  1. You should never edit or add files to the above location!
    Those default Unit files should only be inspected, and never modified.
    Instead, after find an existing Unit file you’d like to use as a template, copy it to either the /system or /user subfolders ast
/etc/systemd/
  1. If you’re modifying an existing systemd service, your copied Unit file will retain the same name and you can edit the file. When a file exists in /etc/systemd/ that also exists in /usr/lib/systemd, the file in /etc/systemd/ will over-ride the default.

If you’re creating a brand new systemd service, then change the Unit file name to what you wish and customize the file as you wish.

  1. If you’re creating a new service, then that’s all you need to do. When completed, you can modify how it runs using the usual systemctl commands.

If you’re modifying an existing service (not new), then you will need to re-load service with the following command. This command should be run after each time you edit an existing Unit file.

systemctl daemon-reload

So,
Step 1 is possibly the most important for getting off to a good start… In your case, you’d probably want to look for an existing Unit file that makes a dbus call or something similar.

HTH,
TSU