Skip to content

Systemd kills user process after logout even if KillUserProcesses is set to no #8486

Description

@Skarlso

Submission type

  • Bug report

systemd version the issue has been seen with

ubuntu@hostname:~$ systemctl --version
systemd 234
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN default-hierarchy=hybrid

In case of bug report: Expected behaviour you didn't see

I expect the user process to remain.

In case of bug report: Unexpected behaviour you saw

The process is still killed.

In case of bug report: Steps to reproduce the problem

I have a user process defined like this:

ubuntu@ip-172-31-56-155:~$ cat .config/systemd/user/my_service.service
[Unit]
Description=Test Service

[Service]
Type=simple
WorkingDirectory=/home/ubuntu
ExecStart=/home/ubuntu/test_service.sh
Restart=always
RemainAfterExit=yes
KillMode=none

[Install]
WantedBy=default.target

The file in question does this:

ubuntu@ip-172-31-56-155:~$ cat test_service.sh
#!/usr/bin/env bash

while true
do
    echo "
 ______
< `date` >
 ------
"
    sleep 1
done

I have the setting in logind.conf:

[Login]
#NAutoVTs=6
#ReserveVT=6
KillUserProcesses=no
#KillOnlyUsers=
KillExcludeUsers=root ubuntu
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%

I can confirm that the status of the service is running when I'm logging out.

Then when I log back in:

Mar 19 13:12:55 ip-172-31-56-155 systemd[1257]: Stopped Test Service.

And the service is no longer running.

I ran out of ideas. I tried upgrading the latest version too as shown by the version indicator. If I remain logged in the service runs fine. I logged in on a different terminal session so had two login prompts and logged out with one of them. The service remained running. Meaning it wasn't tied to a single user session.

Please advice. I would have thought settings these settings makes it so that when I log out my service remains running. And I did read a lot about this and this should absolutely be the behavior I can expect.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions