“The systemd login manager will terminate any user services when their login session ends unless you enable user lingering with the enable-linger option. Use loginctl with the enable-linger option to configure a user to start during the boot process and prevent the systemd service from terminating when the user session ends.” [1]

To enable linger for a user, e.g. kenno, we can run the following command:

# loginctl enable-linger kenno

I usually ran the above command, and that was it. However, today I need to check whether the user kenno had linger enabled already. I also want to document this for my own future reference.

According to [2], there are a few ways to check the linger status of a user. If a user is currently logged in, we can run either one of commands as below:

[kenno@xoa2 ~]$ loginctl list-users
 UID USER  LINGER STATE
1000 kenno no     active

1 users listed.

[kenno@xoa2 ~]$ loginctl user-status kenno | grep -i linger
          Linger: no
                  │ └─355098 grep --color=auto -i linger

Alternatively, we can just list this directory:

[kenno@xoa2 ~]$ ls /var/lib/systemd/linger

In all cases, it doesn’t look like kenno user on xoa2 server has had linger enabled. This explained why the Podman containers run with kenno user quit after running for a little while.

Let’s enable linger for kenno user followed by the verification.

[kenno@xoa2 ~]$ sudo loginctl enable-linger kenno
[sudo] password for kenno:
[kenno@xoa2 ~]$ ls /var/lib/systemd/linger
kenno
[kenno@xoa2 ~]$ loginctl list-users
 UID USER  LINGER STATE
1000 kenno yes    active

1 users listed.
[kenno@xoa2 ~]$ loginctl user-status kenno | grep -i linger
          Linger: yes
                  │ └─355819 grep --color=auto -i linger

That’s it.

References: