Method of instantiating system D unit configuration in Linux

Time:2021-10-17

When running, you may need to instantiate several units of a template. The @ character is used to identify the relationship between the template and the unit file. The instantiated unit can be from another unit file (use the requires or wants option), or use the systemctlstart command. The instantiated service unit can be named as follows:
 

Copy code

The code is as follows:

[email protected]_name.service

Several instances can point to all common instances of the same template file configuration options. For example, the wants option of a unit configuration file can be:

 

Copy code

The code is as follows:

 

First, let SYSTEMd search for a given service unit. If it is not found, SYSTEMd ignores the part between @ and the point number and searches directly [email protected] Service file, read the configuration, and start the service.
Wildcard fields, called cell specifiers, can be used in any cell configuration file. Unit specifiers replace some unit parameters and interpretations at run time. Common unit specifiers are described as follows:
%N the whole unit name, including the suffix of type,% n has the same meaning, but ASCII is replaced by prohibited characters.
%P prefix name, when instantiated,% P represents the part before the @ character.
%I is the direct part of the instance name, @ character and cell type.% I has the same meaning, but ASCII is replaced by prohibited characters.
%H host name, the host name when the configuration file is loaded.
%T runtime directory, the current runtime directory, is the / run directory for root users and XDG for unprivileged users_ RUNTIME_ The directory specified by the dir variable.
for instance, [email protected] Contains the following structure:

 

Copy code

The code is as follows:

[Unit]
Description=Gettyon%I

[Service]
ExecStart=-/sbin/agetty–noclear%I$TERM

 

When [email protected] and [email protected] When instantiating, description = is interpreted as “gettyonttya” and “gettyonttyb”.

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]