Method of instantiating a SYSTEMD unit configuration in Linux

Source: Internet
Author: User

At run time it is possible to instantiate a template with several cells, the @ character is used to identify the relationship between the template and the cell file, the instantiation unit can be from another cell file (using the requires or wants options), or the Systemctlstart command. The Instantiation Service unit can be named in the following way:

The code is as follows:


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

The code is as follows:


First let Systemd search for a given service unit, if not found, Systemd ignores the section between @ and Dot, searches directly for Getty@.service service files, reads the configuration, and starts the service.

Wildcard fields, called cell specifiers, can be used in any unit profile. The unit specifier replaces some units at run time with arguments and explanations. The commonly used cell descriptors are described below:

%n the entire cell name, including the suffix of the type,%n is the same meaning, but ASCII is substituted for the forbidden character.

%p prefix name, when instantiated, the%p represents the part before the @ character.

%i instance name, @ character and unit type direct part. %i is the same meaning, but ASCII replaces the forbidden character.

%H host name, the hostname when the configuration file is loaded.

The%t runtime directory, the current run directory, is the/run directory for the root user, and for the unprivileged user is the directory specified by the Xdg_runtime_dir variable.

For example, Getty@.service contains the following structure:

The code is as follows:







When Getty@ttya.service and Getty@ttyb.service are instantiated, description= is interpreted as "Gettyonttya" and "Gettyonttyb".

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.