You are not logged in.

#1 2017-01-07 11:09:26

ESBDB
Member
Registered: 2017-01-07
Posts: 10

Systemd --user instance not started on login

Hi, according to the wiki, https://wiki.archlinux.org/index.php/Systemd/User "As per default configuration in /etc/pam.d/system-login, the pam_systemd module automatically launches a systemd --user instance when the user logs in for the first time"

However this doesn't seem to be the case. if I run

systemctl status user@esbdb.service

is says

Loaded: loaded (/usr/lib/systemd/system/user@.service; static; vendor preset: disabled); Active: inactive (dead)

and if I try enable it with

sudo systemctl enable user@espada.service

it says

The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
   instance name specified.

However I can successfully do

systemctl start user@esbdb.service

which does start the systemd --user instance.

All the posts I've found about this online just say to do

loginctl enable-linger

however I am not looking to start the user instance on boot, I just want to start it on login as the documentation says it supposedly does.

system info:
running latest arch, I just installed 2 days ago.
kernel: 4.8.13-1-ARCH
Architecture: x86_64
Systemd version: 232-6

Last edited by ESBDB (2017-01-07 11:10:51)

Offline

#2 2017-01-07 14:50:21

rdeckard
Wiki Maintainer
Registered: 2015-01-28
Posts: 137

Re: Systemd --user instance not started on login

Are you sure this is a user unit? None of your systemctl commands have "--user" in them. Also you might have typos in your unit names? Some of them are different.

Offline

#3 2017-01-07 14:55:14

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: Systemd --user instance not started on login

systemctl status user@esbdb.service

This command doesn't show you if the systemd user manager is running, because it doesn't have 'RemainAfterExit=yes'
But you can see if it has run looking into the systemd journal, it shows these lines:

janv. 07 15:09:41 arch64 systemd[1]: Starting User Manager for UID 1000...
...
janv. 07 15:09:41 arch64 systemd[1]: Started User Manager for UID 1000.

And in the list of processes, you should see a line like:

2735 berbae   berbae   15:09:40 /usr/lib/systemd/systemd --user

Edit: see my next post.

Last edited by berbae (2017-01-08 11:28:26)

Offline

#4 2017-01-08 07:27:09

ESBDB
Member
Registered: 2017-01-07
Posts: 10

Re: Systemd --user instance not started on login

@berbae thanks, I don't see why user@esbdb.service would appear inactive from systemctl view if there is actually a daemon running? That is the part of the point of systemd to make it easier to track services.
I can see from the process list and journalctl that my user manager is running, can you elaborate why systemctl doesn't show it as active? The process hasn't exited so why would it need 'RemainAfterExit=yes'?
I'm trying to run a user service sitting in '/home/esbdb/.config/systemd/user/' and yesterday it didn't work until I started the user manager manually. Today I can't reproduce this so I must've been under the wrong impression.

Offline

#5 2017-01-08 11:26:36

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,302

Re: Systemd --user instance not started on login

ESBDB wrote:

I don't see why would appear inactive from systemctl view if there is actually a daemon running?

You are right, I answered too quickly: in fact the name of the service is not 'user@esbdb.service' but 'user@1000.service', and this service is still active after the systemd user manager has been started:

$ systemctl --no-pager status user@berbae.service
● user@berbae.service - User Manager for UID berbae
   Loaded: loaded (/usr/lib/systemd/system/user@.service; static; vendor preset: disabled)
   Active: inactive (dead)

It says the same with an inexistent user:

$ systemctl --no-pager status user@zzzzzzz.service
● user@zzzzzzz.service - User Manager for UID zzzzzzz
   Loaded: loaded (/usr/lib/systemd/system/user@.service; static; vendor preset: disabled)
   Active: inactive (dead)

But

$ systemctl --no-pager status user@1000.service
● user@1000.service - User Manager for UID 1000
   Loaded: loaded (/usr/lib/systemd/system/user@.service; static; vendor preset: disabled)
   Active: active (running) since Sun 2017-01-08 10:40:14 CET; 1h 15min ago
 Main PID: 2377 (systemd)
   Status: "Startup finished in 135ms."
    Tasks: 21
   CGroup: /user.slice/user-1000.slice/user@1000.service
           ├─at-spi-dbus-bus.service
           │ ├─3388 /usr/lib/at-spi2-core/at-spi-bus-launcher
           │ ├─3393 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
           │ └─3395 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
           ├─dbus.service
           │ ├─2421 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation
           │ ├─2554 /usr/lib/GConf/gconfd-2
           │ └─3387 /usr/lib/notify-osd/notify-osd
           ├─init.scope
           │ ├─2377 /usr/lib/systemd/systemd --user
           │ └─2378 (sd-pam)
           └─pulseaudio.service
             ├─2539 /usr/bin/pulseaudio --daemonize=no
             └─2552 /usr/lib/pulse/gconf-helper

janv. 08 10:41:37 arch64 systemd[2377]: Started Sound Service.
janv. 08 11:46:51 arch64 dbus-daemon[2421]: Activating service name='org.freedesktop.Notifications'
janv. 08 11:46:51 arch64 dbus-daemon[2421]: Activating via systemd: service name='org.a11y.Bus' unit='at-spi-dbus-bus.service'
...

The 'RemainAfterExit=' is for 'oneshot' type services.
Sorry for the error.

Last edited by berbae (2017-01-08 11:31:25)

Offline

#6 2017-01-08 18:49:52

ESBDB
Member
Registered: 2017-01-07
Posts: 10

Re: Systemd --user instance not started on login

@berbae thanks, that's quite annoying that it uses the uid instead of the name, but at least I know now. I guess this problem is resolved, I think my error was that I didn't reload the daemon after creating the unit file so it didn't work. I then started a second user manager with 'user@esbdb.service' which made the unit file work (it possibly conflicted with user@1000.service). Anyway it seems to be working now.

Offline

Board footer

Powered by FluxBB