0

I have a system service that is executed for selected users. Name is serv@<uid> (<uid> is UID of the user). I want to share user's resource limits with the service (place it into user-<uid>.slice) and I also want to use his permissions.

/etc/systemd/system/serv@.service

[Unit]
Description=My service for user %i

[Service]
Type=simple
ExecStart=/usr/local/bin/serv.sh
Restart=always
User=%i
Slice=user-%i.slice
SuccessExitStatus=0 255 SIGKILL SIGTERM

[Install]
WantedBy=multi-user.target

When the user logs out, the service is terminated using SIGTERM. Why isn't the service restarted? How can I set it up so the service will not be terminated?

0

You can change logind configuration:

/etc/systemd/logind.conf

[Login]
…
KillUserProcesses=no
…

This also changes behavior for other services and background processes (like screen, tmux). See issue #3483;


Run systemctl restart systemd-logind after that.

  • I use tmux and others so it will solve multiple problems at once. – jiwopene May 28 at 15:14
0

For me the solution was loginctl enable-linger username. Without this the service would die when the user logged out. https://wiki.archlinux.org/index.php/Systemd/User#Automatic_start-up_of_systemd_user_instances

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.