конфигурация сервисного блока (Service unit configuration)
COMMAND LINES
This section describes command line parsing and variable and
specifier substitutions for ExecStart=, ExecStartPre=,
ExecStartPost=, ExecReload=, ExecStop=, and ExecStopPost=
options.
Multiple command lines may be concatenated in a single directive
by separating them with semicolons (these semicolons must be
passed as separate words). Lone semicolons may be escaped as
"\;".
Each command line is unquoted using the rules described in
"Quoting" section in systemd.syntax(7). The first item becomes
the command to execute, and the subsequent items the arguments.
This syntax is inspired by shell syntax, but only the
meta-characters and expansions described in the following
paragraphs are understood, and the expansion of variables is
different. Specifically, redirection using "<", "<<", ">", and
">>", pipes using "|", running programs in the background using
"&", and other elements of shell syntax are not supported.
The command to execute may contain spaces, but control characters
are not allowed.
The command line accepts "%" specifiers as described in
systemd.unit(5).
Basic environment variable substitution is supported. Use
"${FOO}" as part of a word, or as a word of its own, on the
command line, in which case it will be erased and replaced by the
exact value of the environment variable (if any) including all
whitespace it contains, always resulting in exactly a single
argument. Use "$FOO" as a separate word on the command line, in
which case it will be replaced by the value of the environment
variable split at whitespace, resulting in zero or more
arguments. For this type of expansion, quotes are respected when
splitting into words, and afterwards removed.
If the command is not a full (absolute) path, it will be resolved
to a full path using a fixed search path determined at
compilation time. Searched directories include /usr/local/bin/,
/usr/bin/, /bin/ on systems using split /usr/bin/ and /bin/
directories, and their sbin/ counterparts on systems using split
bin/ and sbin/. It is thus safe to use just the executable name
in case of executables located in any of the "standard"
directories, and an absolute path must be used in other cases.
Using an absolute path is recommended to avoid ambiguity. Hint:
this search path may be queried using systemd-path
search-binaries-default
.
Example:
Environment="ONE=one" 'TWO=two two'
ExecStart=echo $ONE $TWO ${TWO}
This will execute /bin/echo
with four arguments: "one", "two",
"two", and "two two".
Example:
Environment=ONE='one' "TWO='two two' too" THREE=
ExecStart=/bin/echo ${ONE} ${TWO} ${THREE}
ExecStart=/bin/echo $ONE $TWO $THREE
This results in /bin/echo being called twice, the first time with
arguments "'one'", "'two two' too", "", and the second time with
arguments "one", "two two", "too".
To pass a literal dollar sign, use "$$". Variables whose value is
not known at expansion time are treated as empty strings. Note
that the first argument (i.e. the program to execute) may not be
a variable.
Variables to be used in this fashion may be defined through
Environment= and EnvironmentFile=. In addition, variables listed
in the section "Environment variables in spawned processes" in
systemd.exec(5), which are considered "static configuration", may
be used (this includes e.g. $USER, but not $TERM).
Note that shell command lines are not directly supported. If
shell command lines are to be used, they need to be passed
explicitly to a shell implementation of some kind. Example:
ExecStart=sh -c 'dmesg | tac'
Example:
ExecStart=echo one ; echo "two two"
This will execute echo
two times, each time with one argument:
"one" and "two two", respectively. Because two commands are
specified, Type=oneshot must be used.
Example:
ExecStart=echo / >/dev/null & \; \
ls
This will execute echo
with five arguments: "/", ">/dev/null",
"&", ";", and "ls".