Before You Begin

This tutorial shows you how to set up the systemd service manager on an Oracle Linux 8 system to ensure that services and processes that are started by a user continue after the user's session has ended.

Background

Systemd is a software suite that is designed to replace the init system that is used to bootstrap userspace and manage user processes on Linux systems. Systemd is more robust and can replace existing daemons and utilities for user management, login sessions, and networking.

By default, services and processes that are started and owned by a user are terminated when that user's login session ends. The loginctl command can be used to change this default behavior.

What Do You Need?


Enable processes to continue by using the loginctl utility

Use the loginctl utility to change the default behavior for the users that you specify, for example:

$ sudo loginctl enable-linger user

To verify that the setting has been applied, check for a file with the same name as the user in the /var/lib/systemd/linger directory.



Enable processes to continue for specified users by using the logind.conf file

Edit the /etc/systemd/logind.conf file by entering a space-separated list of users for the KillExcludeUsers parameter. The configuration ensures that user-owned services and processes continue for these users, for example:

KillExcludeUsers=user1 user2 user3


Enable processes to continue for all users by using the logind.conf file

Open the /etc/systemd/logind.conf file for editing and uncomment the KillUserProcesses setting as follows:

KillUserProcesses=no

To reinstate the previous behavior, modify the KillOnlyUsers setting by specifying a space-separated list of the selected users, for example:

KillOnlyUsers=user1 user2 user3

Want to Learn More?