Вы находитесь на странице: 1из 10

In the name of God

Systemd
What is systemd

system and service manager for Linux

Controls all resources on the system reffered to
as unit

Systemd runs as daemon with PID 1.

It is the mother of all processes

Start as much in parallel as possible

Only start when needed to start

Systemd tasks are organized as units.
units

Systemd tasks are organized as units.

systemd records initialization instructions for
each daemon in a configuration file (referred to
as a "unit file")

/etc/systemd/system/
units

Systemd has 12 unit types:

Service > Daemon and servises

Socket > Daemon on Socket start

Device > Drivers

Mount > Partitions

Automount > Removable and network drives

Swap > Swap files

Target > Group units

Path > file system changes

Timer > service scheduling

Snapshot > save the state of all services

slice (used to group and manage processes and resources[17])

scope
Systemctl

The main tool used to introspect and control the state of
the systemd

Status

List-unit-files

--failed

Start

Stop

Restart

enable/disable
How to create a new systemd unit
file

system administrator must edit or create unit files
manually

Unit files can be supplemented with a directory for
additional configuration files

<un>.service.wants/ and <un>.service.requires/
contain symbolic links to unit files that are
dependencies of this service.

The symbolic links are automatically created either
during installation according to [Install] unit file options
unit file

Unit files typically consist of three sections:

[Unit] contains generic options that are not dependent
on the type of the unit. These options provide unit
description, specify the unit's behavior, and set
dependencies to other units.

[unit type] if a unit has type-specific directives, these
are grouped under a section named after the unit type.

[Install] contains information about unit installation
used by systemctl enable and disable commands
Unit file example(1)
[Unit]

Description=service_description
After=network.target

[Service]

ExecStart=path_to_executable
Type=forking
PIDFile=path_to_pidfile

[Install]

WantedBy=default.target
Unit file example(2)

service_description is an informative description that is displayed in
journal log files and in the output of the systemctl status command.

After ensures that the service is started only after the network is
running. Add a space-separated list of other relevant services or
targets.

path_to_executable stands for the path to the actual service
executable.

Type=forking is used for daemons that make the fork system call.
The main process of the service is created with the PID specified in
path_to_pidfile.

WantedBy states the target or targets that the service should be
started under.
Unit file example(3)

After complete the installation procedure, run the
following command:
systemctl daemon-reload
systemctl start name.service

Always run the systemctl daemon-reload command
after creating new unit files or modifying existing unit
files. Otherwise, the systemctl start or systemctl enable
commands could fail due to a mismatch between states
of systemd and actual service unit files on disk

Вам также может понравиться