Debian Codegraph @

upstream/debian-unstable/man1/systemd-run.1

raw
1 '\" t
2 .TH "SYSTEMD\-RUN" "1" "" "systemd 261~rc3" "systemd-run"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 systemd-run \- Run programs in transient scope units, service units, or path\-, socket\-, or timer\-triggered service units
24 .SH "SYNOPSIS"
25 .HP \w'\fBsystemd\-run\fR\ 'u
26 \fBsystemd\-run\fR [OPTIONS...] \fICOMMAND\fR\ [ARGS...]
27 .HP \w'\fBsystemd\-run\fR\ 'u
28 \fBsystemd\-run\fR [OPTIONS...] [PATH\ OPTIONS...] {\fICOMMAND\fR\ [ARGS...]}
29 .HP \w'\fBsystemd\-run\fR\ 'u
30 \fBsystemd\-run\fR [OPTIONS...] [SOCKET\ OPTIONS...] {\fICOMMAND\fR\ [ARGS...]}
31 .HP \w'\fBsystemd\-run\fR\ 'u
32 \fBsystemd\-run\fR [OPTIONS...] [TIMER\ OPTIONS...] {\fICOMMAND\fR\ [ARGS...]}
33 .SH "DESCRIPTION"
34 .PP
35 \fBsystemd\-run\fR
36 may be used to create and start a transient
37 \&.service
38 or
39 \&.scope
40 unit and run the specified
41 \fICOMMAND\fR
42 in it\&. It may also be used to create and start a transient
43 \&.path,
44 \&.socket, or
45 \&.timer
46 unit, that activates a
47 \&.service
48 unit when elapsing\&.
49 .PP
50 If a command is run as transient service unit, it will be started and managed by the service manager like any other service, and thus shows up in the output of
51 \fBsystemctl list\-units\fR
52 like any other unit\&. It will run in a clean and detached execution environment, with the service manager as its parent process\&. In this mode,
53 \fBsystemd\-run\fR
54 will start the service asynchronously in the background and return after the command has begun execution (unless
55 \fB\-\-no\-block\fR,
56 \fB\-\-wait\fR,
57 \fB\-\-pipe\fR, or
58 \fB\-\-pty\fR
59 are specified, see below)\&.
60 .PP
61 If a command is run as transient scope unit, it will be executed by
62 \fBsystemd\-run\fR
63 itself as parent process and will thus inherit the execution environment of the caller\&. However, the processes of the command are managed by the service manager similarly to normal services, and will show up in the output of
64 \fBsystemctl list\-units\fR\&. Execution in this case is synchronous, and will return only when the command finishes\&. This mode is enabled via the
65 \fB\-\-scope\fR
66 switch (see below)\&.
67 .PP
68 If a command is run with path, socket, or timer options such as
69 \fB\-\-on\-calendar=\fR
70 (see below), a transient path, socket, or timer unit is created alongside the service unit for the specified command\&. Only the transient path, socket, or timer unit is started immediately, the transient service unit will be triggered by the path, socket, or timer unit\&. If the
71 \fB\-\-unit=\fR
72 option is specified, the
73 \fICOMMAND\fR
74 may be omitted\&. In this case,
75 \fBsystemd\-run\fR
76 creates only a
77 \&.path,
78 \&.socket, or
79 \&.timer
80 unit that triggers the specified unit\&.
81 .PP
82 By default, services created with
83 \fBsystemd\-run\fR
84 default to the
85 \fBsimple\fR
86 type, see the description of
87 \fIType=\fR
88 in
89 \fBsystemd.service\fR(5)
90 for details\&. Note that when this type is used, the service manager (and thus the
91 \fBsystemd\-run\fR
92 command) considers service start\-up successful as soon as the
93 \fBfork()\fR
94 for the main service process succeeded, i\&.e\&. before the
95 \fBexecve()\fR
96 is invoked, and thus even if the specified command cannot be started\&. Consider using the
97 \fBexec\fR
98 service type (i\&.e\&.
99 \fB\-\-property=Type=exec\fR) to ensure that
100 \fBsystemd\-run\fR
101 returns successfully only if the specified command line has been successfully started\&.
102 .PP
103 After
104 \fBsystemd\-run\fR
105 passes the command to the service manager, the manager performs variable expansion\&. This means that dollar characters ("$") which should not be expanded need to be escaped as
106 "$$"\&. Expansion can also be disabled using
107 \fI\-\-expand\-environment=no\fR\&.
108 .SH "OPTIONS"
109 .PP
110 The following options are understood:
111 .PP
112 \fB\-\-scope\fR
113 .RS 4
114 Create a transient
115 \&.scope
116 unit instead of the default transient
117 \&.service
118 unit (see above)\&.
119 .sp
120 Added in version 206\&.
121 .RE
122 .PP
123 \fB\-\-unit=\fR, \fB\-u\fR
124 .RS 4
125 Use this unit name instead of an automatically generated one\&.
126 .sp
127 Added in version 206\&.
128 .RE
129 .PP
130 \fB\-\-property=\fR, \fB\-p\fR
131 .RS 4
132 Sets a property on the scope or service unit that is created\&. This option takes an assignment in the same format as
133 \fBsystemctl\fR(1)\*(Aqs
134 \fBset\-property\fR
135 command\&.
136 .sp
137 Added in version 211\&.
138 .RE
139 .PP
140 \fB\-\-description=\fR
141 .RS 4
142 Provide a description for the service, scope, path, socket, or timer unit\&. If not specified, the command itself will be used as a description\&. See
143 \fIDescription=\fR
144 in
145 \fBsystemd.unit\fR(5)\&.
146 .sp
147 Added in version 206\&.
148 .RE
149 .PP
150 \fB\-\-slice=\fR
151 .RS 4
152 Make the new
153 \&.service
154 or
155 \&.scope
156 unit part of the specified slice, instead of
157 system\&.slice
158 (when running in
159 \fB\-\-system\fR
160 mode) or the root slice (when running in
161 \fB\-\-user\fR
162 mode)\&.
163 .sp
164 Added in version 206\&.
165 .RE
166 .PP
167 \fB\-\-slice\-inherit\fR
168 .RS 4
169 Make the new
170 \&.service
171 or
172 \&.scope
173 unit part of the slice the
174 \fBsystemd\-run\fR
175 itself has been invoked in\&. This option may be combined with
176 \fB\-\-slice=\fR, in which case the slice specified via
177 \fB\-\-slice=\fR
178 is placed within the slice the
179 \fBsystemd\-run\fR
180 command is invoked in\&.
181 .sp
182 Example: consider
183 \fBsystemd\-run\fR
184 being invoked in the slice
185 foo\&.slice, and the
186 \fB\-\-slice=\fR
187 argument is
188 bar\&. The unit will then be placed under
189 foo\-bar\&.slice\&.
190 .sp
191 Added in version 246\&.
192 .RE
193 .PP
194 \fB\-\-expand\-environment=\fR\fB\fIBOOL\fR\fR
195 .RS 4
196 Expand environment variables in command arguments\&. If enabled (the default), environment variables specified as
197 "${\fIVARIABLE\fR}"
198 will be expanded in the same way as in commands specified via
199 \fIExecStart=\fR
200 in units\&. With
201 \fI\-\-scope\fR, this expansion is performed by
202 \fBsystemd\-run\fR
203 itself, and in other cases by the service manager that spawns the command\&. Note that this is similar to, but not the same as variable expansion in
204 \fBbash\fR(1)
205 and other shells\&.
206 .sp
207 See
208 \fBsystemd.service\fR(5)
209 for a description of variable expansion\&. Disabling variable expansion is useful if the specified command includes or may include a
210 "$"
211 sign\&.
212 .sp
213 Added in version 254\&.
214 .RE
215 .PP
216 \fB\-r\fR, \fB\-\-remain\-after\-exit\fR
217 .RS 4
218 After the service process has terminated, keep the service around until it is explicitly stopped\&. This is useful to collect runtime information about the service after it finished running\&. Also see
219 \fIRemainAfterExit=\fR
220 in
221 \fBsystemd.service\fR(5)\&.
222 .sp
223 Added in version 207\&.
224 .RE
225 .PP
226 \fB\-\-send\-sighup\fR
227 .RS 4
228 When terminating the scope or service unit, send a SIGHUP immediately after SIGTERM\&. This is useful to indicate to shells and shell\-like processes that the connection has been severed\&. Also see
229 \fISendSIGHUP=\fR
230 in
231 \fBsystemd.kill\fR(5)\&.
232 .sp
233 Added in version 207\&.
234 .RE
235 .PP
236 \fB\-\-service\-type=\fR
237 .RS 4
238 Sets the service type\&. Also see
239 \fIType=\fR
240 in
241 \fBsystemd.service\fR(5)\&. This option has no effect in conjunction with
242 \fB\-\-scope\fR\&. Defaults to
243 \fBsimple\fR\&.
244 .sp
245 Added in version 211\&.
246 .RE
247 .PP
248 \fB\-\-uid=\fR, \fB\-\-gid=\fR
249 .RS 4
250 Runs the service process under the specified UNIX user and group\&. Also see
251 \fIUser=\fR
252 and
253 \fIGroup=\fR
254 in
255 \fBsystemd.exec\fR(5)\&.
256 .sp
257 Added in version 211\&.
258 .RE
259 .PP
260 \fB\-\-nice=\fR
261 .RS 4
262 Runs the service process with the specified nice level\&. Also see
263 \fINice=\fR
264 in
265 \fBsystemd.exec\fR(5)\&.
266 .sp
267 Added in version 211\&.
268 .RE
269 .PP
270 \fB\-\-working\-directory=\fR
271 .RS 4
272 Runs the service process with the specified working directory\&. Also see
273 \fIWorkingDirectory=\fR
274 in
275 \fBsystemd.exec\fR(5)\&.
276 .sp
277 Added in version 240\&.
278 .RE
279 .PP
280 \fB\-\-same\-dir\fR, \fB\-d\fR
281 .RS 4
282 Similar to
283 \fB\-\-working\-directory=\fR, but uses the current working directory of the caller for the service to execute\&.
284 .sp
285 Added in version 240\&.
286 .RE
287 .PP
288 \fB\-\-root\-directory=\fR
289 .RS 4
290 Runs the service process with the specified root directory\&. Also see
291 \fIRootDirectory=\fR
292 in
293 \fBsystemd.exec\fR(5)\&.
294 .sp
295 Note that the path is looked up inside the file system namespace that systemd\-run is running in, which might be different that the file system namespace the manager process is running in\&. Use the
296 \fIRootDirectory=\fR
297 property directly if you want the path to be looked up in the manager process\*(Aqs file system namespace\&.
298 .sp
299 Added in version 259\&.
300 .RE
301 .PP
302 \fB\-\-same\-root\-dir\fR, \fB\-R\fR
303 .RS 4
304 Similar to
305 \fB\-\-root\-directory=\fR, but uses the root directory of the systemd\-run process as the root directory to execute the service in\&.
306 .sp
307 Added in version 259\&.
308 .RE
309 .PP
310 \fB\-E \fR\fB\fINAME\fR\fR\fB[=\fR\fB\fIVALUE\fR\fR\fB]\fR, \fB\-\-setenv=\fR\fB\fINAME\fR\fR\fB[=\fR\fB\fIVALUE\fR\fR\fB]\fR
311 .RS 4
312 Runs the service process with the specified environment variable set\&. This parameter may be used more than once to set multiple variables\&. When
313 "="
314 and
315 \fIVALUE\fR
316 are omitted, the value of the variable with the same name in the program environment will be used\&.
317 .sp
318 Also see
319 \fIEnvironment=\fR
320 in
321 \fBsystemd.exec\fR(5)\&.
322 .sp
323 Added in version 211\&.
324 .RE
325 .PP
326 \fB\-\-pty\fR, \fB\-t\fR
327 .RS 4
328 When invoking the command, the transient service connects its standard input, output and error to the terminal
329 \fBsystemd\-run\fR
330 is invoked on, via a pseudo TTY device\&. This allows running programs that expect interactive user input/output as services, such as interactive command shells\&.
331 .sp
332 This option will result in
333 \fBsystemd\-run\fR
334 synchronously waiting for the transient service to terminate, similar to specifying
335 \fB\-\-wait\fR\&. If specified along with
336 \fB\-\-wait\fR,
337 \fBsystemd\-run\fR
338 will not exit when manually disconnecting from the pseudo TTY device\&.
339 .sp
340 Note that
341 \fBmachinectl\fR(1)\*(Aqs
342 \fBshell\fR
343 command is usually a better alternative for requesting a new, interactive login session on the local host or a local container\&.
344 .sp
345 See below for details on how this switch combines with
346 \fB\-\-pipe\fR\&.
347 .sp
348 Added in version 219\&.
349 .RE
350 .PP
351 \fB\-\-pty\-late\fR, \fB\-T\fR
352 .RS 4
353 Much like
354 \fB\-\-pty\fR, but the PTY communication only begins once the unit start is complete\&. This effectively means PTY input during
355 \fIExecStartPre=\fR
356 of a service is not available while using
357 \fB\-\-pty\-late\fR, while it is available using
358 \fB\-\-pty\fR, for most service types\&. However, if this option is used, access to the invoking TTY is available for password queries (see
359 \fB\-\-no\-ask\-password\fR
360 below) during unit start\-up\&.
361 .sp
362 Added in version 258\&.
363 .RE
364 .PP
365 \fB\-\-pipe\fR, \fB\-P\fR
366 .RS 4
367 If specified, standard input, output, and error of the transient service are inherited from the
368 \fBsystemd\-run\fR
369 command itself\&. This allows
370 \fBsystemd\-run\fR
371 to be used within shell pipelines\&.
372 .sp
373 Note that this mode is not suitable for interactive command shells and similar, as the service process will not become a TTY controller when invoked on a terminal\&. Use
374 \fB\-\-pty\fR
375 instead in that case\&.
376 .sp
377 When both
378 \fB\-\-pipe\fR
379 and
380 \fB\-\-pty\fR
381 are used in combination the more appropriate option is automatically determined and used\&. Specifically, when invoked with standard input, output and error connected to a TTY
382 \fB\-\-pty\fR
383 is used, and otherwise
384 \fB\-\-pipe\fR\&.
385 .sp
386 This option will result in
387 \fBsystemd\-run\fR
388 synchronously waiting for the transient service to terminate, similar to specifying
389 \fB\-\-wait\fR\&.
390 .sp
391 When this option is used the original file descriptors
392 \fBsystemd\-run\fR
393 receives are passed to the service processes as\-is\&. If the service runs with different privileges than
394 \fBsystemd\-run\fR, this means the service might not be able to reopen the passed file descriptors, due to normal file descriptor access restrictions\&. If the invoked process is a shell script that uses the
395 \fBecho "hello" >/dev/stderr\fR
396 construct for writing messages to stderr, this might cause problems, as this only works if stderr can be reopened\&. To mitigate this use the construct
397 \fBecho "hello" >&2\fR
398 instead, which is mostly equivalent and avoids this pitfall\&.
399 .sp
400 Added in version 235\&.
401 .RE
402 .PP
403 \fB\-\-shell\fR, \fB\-S\fR
404 .RS 4
405 A shortcut for
406 "\-\-pty \-\-same\-dir \-\-wait \-\-collect \-\-service\-type=exec $SHELL", i\&.e\&. requests an interactive shell in the current working directory, running in service context, accessible with a single switch\&.
407 .sp
408 Added in version 240\&.
409 .RE
410 .PP
411 \fB\-\-quiet\fR, \fB\-q\fR
412 .RS 4
413 Suppresses additional informational output while running\&. This is particularly useful in combination with
414 \fB\-\-pty\fR
415 when it will suppress the initial message explaining how to terminate the TTY connection\&.
416 .sp
417 Added in version 219\&.
418 .RE
419 .PP
420 \fB\-v\fR, \fB\-\-verbose\fR
421 .RS 4
422 Display unit log output while running\&.
423 .sp
424 Added in version 258\&.
425 .RE
426 .PP
427 \fB\-\-output=\fR
428 .RS 4
429 Controls the formatting of verbose unit log output, see
430 \fBjournalctl\fR(1)
431 for possible values\&.
432 .sp
433 Added in version 261\&.
434 .RE
435 .PP
436 \fB\-\-on\-active=\fR, \fB\-\-on\-boot=\fR, \fB\-\-on\-startup=\fR, \fB\-\-on\-unit\-active=\fR, \fB\-\-on\-unit\-inactive=\fR
437 .RS 4
438 Defines a monotonic timer relative to different starting points for starting the specified command\&. See
439 \fIOnActiveSec=\fR,
440 \fIOnBootSec=\fR,
441 \fIOnStartupSec=\fR,
442 \fIOnUnitActiveSec=\fR
443 and
444 \fIOnUnitInactiveSec=\fR
445 in
446 \fBsystemd.timer\fR(5)
447 for details\&. These options are shortcuts for
448 \fB\-\-timer\-property=\fR
449 with the relevant properties\&. These options may not be combined with
450 \fB\-\-scope\fR
451 or
452 \fB\-\-pty\fR\&.
453 .sp
454 Added in version 218\&.
455 .RE
456 .PP
457 \fB\-\-on\-calendar=\fR
458 .RS 4
459 Defines a calendar timer for starting the specified command\&. See
460 \fIOnCalendar=\fR
461 in
462 \fBsystemd.timer\fR(5)\&. This option is a shortcut for
463 \fB\-\-timer\-property=OnCalendar=\fR\&. This option may not be combined with
464 \fB\-\-scope\fR
465 or
466 \fB\-\-pty\fR\&.
467 .sp
468 Added in version 218\&.
469 .RE
470 .PP
471 \fB\-\-on\-clock\-change\fR, \fB\-\-on\-timezone\-change\fR
472 .RS 4
473 Defines a trigger based on system clock jumps or timezone changes for starting the specified command\&. See
474 \fIOnClockChange=\fR
475 and
476 \fIOnTimezoneChange=\fR
477 in
478 \fBsystemd.timer\fR(5)\&. These options are shortcuts for
479 \fB\-\-timer\-property=OnClockChange=yes\fR
480 and
481 \fB\-\-timer\-property=OnTimezoneChange=yes\fR\&. These options may not be combined with
482 \fB\-\-scope\fR
483 or
484 \fB\-\-pty\fR\&.
485 .sp
486 Added in version 242\&.
487 .RE
488 .PP
489 \fB\-\-path\-property=\fR, \fB\-\-socket\-property=\fR, \fB\-\-timer\-property=\fR
490 .RS 4
491 Sets a property on the path, socket, or timer unit that is created\&. This option is similar to
492 \fB\-\-property=\fR, but applies to the transient path, socket, or timer unit rather than the transient service unit created\&. This option takes an assignment in the same format as
493 \fBsystemctl\fR(1)\*(Aqs
494 \fBset\-property\fR
495 command\&. These options may not be combined with
496 \fB\-\-scope\fR
497 or
498 \fB\-\-pty\fR\&.
499 .sp
500 Added in version 218\&.
501 .RE
502 .PP
503 \fB\-\-no\-block\fR
504 .RS 4
505 Do not synchronously wait for the unit start operation to finish\&. If this option is not specified, the start request for the transient unit will be verified, enqueued and
506 \fBsystemd\-run\fR
507 will wait until the unit\*(Aqs start\-up is completed\&. By passing this argument, it is only verified and enqueued\&. This option may not be combined with
508 \fB\-\-wait\fR\&.
509 .sp
510 Added in version 220\&.
511 .RE
512 .PP
513 \fB\-\-wait\fR
514 .RS 4
515 Synchronously wait for the transient service to terminate\&. If this option is specified, the start request for the transient unit is verified, enqueued, and waited for\&. Subsequently the invoked unit is monitored, and it is waited until it is deactivated again (most likely because the specified command completed)\&. On exit, terse information about the unit\*(Aqs runtime is shown, including total runtime (as well as CPU, memory, IO, and IP accounting data, if the corresponding cgroup accounting settings are enabled) and the exit code and status of the main process\&. This output may be suppressed with
516 \fB\-\-quiet\fR\&. This option may not be combined with
517 \fB\-\-no\-block\fR,
518 \fB\-\-scope\fR
519 or the various path, socket, or timer options\&.
520 .sp
521 Added in version 232\&.
522 .RE
523 .PP
524 \fB\-G\fR, \fB\-\-collect\fR
525 .RS 4
526 Unload the transient unit after it completed, even if it failed\&. Normally, without this option, all units that ran and failed are kept in memory until the user explicitly resets their failure state with
527 \fBsystemctl reset\-failed\fR
528 or an equivalent command\&. On the other hand, units that ran successfully are unloaded immediately\&. If this option is turned on the "garbage collection" of units is more aggressive, and unloads units regardless of whether they exited successfully or failed\&. This option is a shortcut for
529 \fB\-\-property=CollectMode=inactive\-or\-failed\fR, see the explanation for
530 \fICollectMode=\fR
531 in
532 \fBsystemd.unit\fR(5)
533 for further information\&.
534 .sp
535 Added in version 236\&.
536 .RE
537 .PP
538 \fB\-\-job\-mode=\fR\fB\fIMODE\fR\fR
539 .RS 4
540 When queuing a new job, this option controls how to deal with already queued jobs\&.
541 .sp
542 The option takes the same mode values as
543 \fBsystemctl\fR(1)\*(Aqs
544 \fB\-\-job\-mode=\fR
545 option\&. The default job mode is
546 "fail"\&.
547 .sp
548 Running
549 \fB\-\-job\-mode=help\fR
550 shows a list of available job modes\&.
551 .sp
552 Added in version 258\&.
553 .RE
554 .PP
555 \fB\-\-ignore\-failure\fR
556 .RS 4
557 By default, if the specified command fails the invoked unit will be marked failed (though possibly still unloaded, see
558 \fB\-\-collect=\fR, above), and this is reported in the logs\&. If this switch is specified this is suppressed and any non\-success exit status/code of the command is treated as success\&.
559 .sp
560 Added in version 256\&.
561 .RE
562 .PP
563 \fB\-\-background=\fR\fB\fICOLOR\fR\fR
564 .RS 4
565 Change the terminal background color to the specified ANSI color as long as the session lasts\&. The color specified should be an ANSI X3\&.64 SGR background color, i\&.e\&. strings such as
566 "40",
567 "41", \&...,
568 "47",
569 "48;2;\&...",
570 "48;5;\&..."\&. See
571 \m[blue]\fBANSI Escape Code (Wikipedia)\fR\m[]\&\s-2\u[1]\d\s+2
572 for details\&.
573 .sp
574 Added in version 256\&.
575 .RE
576 .PP
577 \fB\-\-user\fR
578 .RS 4
579 Talk to the service manager of the calling user, rather than the service manager of the system\&.
580 .RE
581 .PP
582 \fB\-\-system\fR
583 .RS 4
584 Talk to the service manager of the system\&. This is the implied default\&.
585 .RE
586 .PP
587 \fB\-H\fR, \fB\-\-host=\fR
588 .RS 4
589 Execute the operation remotely\&. Specify a hostname, or a username and hostname separated by
590 "@", to connect to\&. The hostname may optionally be suffixed by a port ssh is listening on, separated by
591 ":", and then a container name, separated by
592 "/", which connects directly to a specific container on the specified host\&. This will use SSH to talk to the remote machine manager instance\&. Container names may be enumerated with
593 \fBmachinectl \-H \fR\fB\fIHOST\fR\fR\&. Put IPv6 addresses in brackets\&.
594 .RE
595 .PP
596 \fB\-M\fR, \fB\-\-machine=\fR
597 .RS 4
598 Execute operation on a local container\&. Specify a container name to connect to, optionally prefixed by a user name to connect as and a separating
599 "@"
600 character\&. If the special string
601 "\&.host"
602 is used in place of the container name, a connection to the local system is made (which is useful to connect to a specific user\*(Aqs user bus:
603 "\-\-user \-\-machine=lennart@\&.host")\&. If the
604 "@"
605 syntax is not used, the connection is made as root user\&. If the
606 "@"
607 syntax is used either the left hand side or the right hand side may be omitted (but not both) in which case the local user name and
608 "\&.host"
609 are implied\&.
610 .RE
611 .PP
612 \fB\-C\fR, \fB\-\-capsule=\fR
613 .RS 4
614 Execute operation on a capsule\&. Specify a capsule name to connect to\&. See
615 \[email protected]\fR(5)
616 for details about capsules\&.
617 .sp
618 Added in version 256\&.
619 .RE
620 .PP
621 \fB\-\-no\-ask\-password\fR
622 .RS 4
623 Do not query the user for authentication for privileged operations\&.
624 .RE
625 .PP
626 \fB\-h\fR, \fB\-\-help\fR
627 .RS 4
628 Print a short help text and exit\&.
629 .RE
630 .PP
631 \fB\-\-version\fR
632 .RS 4
633 Print a short version string and exit\&.
634 .RE
635 .PP
636 \fB\-\-json=\fR\fB\fIMODE\fR\fR
637 .RS 4
638 Shows output formatted as JSON\&. Expects one of
639 "short"
640 (for the shortest possible output without any redundant whitespace or line breaks),
641 "pretty"
642 (for a pretty version of the same, with indentation and line breaks) or
643 "off"
644 (to turn off JSON output, the default)\&.
645 .RE
646 .PP
647 \fB\-\-no\-pager\fR
648 .RS 4
649 Do not pipe output into a pager\&. This currently only applies to
650 \fB\-\-help\fR\&. (The pager is not started during normal operation\&.)
651 .sp
652 Added in version 258\&.
653 .RE
654 .PP
655 All command line arguments after the first non\-option argument become part of the command line of the launched process\&.
656 .SH "EXIT STATUS"
657 .PP
658 On success, 0 is returned\&. If
659 \fBsystemd\-run\fR
660 failed to start the service, a non\-zero return value will be returned\&. If
661 \fBsystemd\-run\fR
662 waits for the service to terminate, the return value will be propagated from the service\&. 0 will be returned on success, including all the cases where systemd considers a service to have exited cleanly, see the discussion of
663 \fISuccessExitStatus=\fR
664 in
665 \fBsystemd.service\fR(5)\&.
666 .SH "EXAMPLES"
667 .PP
668 \fBExample\ \&1.\ \&Logging environment variables provided by systemd to services\fR
669 .sp
670 .if n \{\
671 .RS 4
672 .\}
673 .nf
674 # systemd\-run env
675 Running as unit: run\-19945\&.service
676 # journalctl \-u run\-19945\&.service
677 Sep 08 07:37:21 bupkis systemd[1]: Starting /usr/bin/env\&.\&.\&.
678 Sep 08 07:37:21 bupkis systemd[1]: Started /usr/bin/env\&.
679 Sep 08 07:37:21 bupkis env[19948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
680 Sep 08 07:37:21 bupkis env[19948]: LANG=en_US\&.UTF\-8
681 Sep 08 07:37:21 bupkis env[19948]: BOOT_IMAGE=/vmlinuz\-3\&.11\&.0\-0\&.rc5\&.git6\&.2\&.fc20\&.x86_64
682 .fi
683 .if n \{\
684 .RE
685 .\}
686 .PP
687 \fBExample\ \&2.\ \&Limiting resources available to a command\fR
688 .sp
689 .if n \{\
690 .RS 4
691 .\}
692 .nf
693 # systemd\-run \-p IOWeight=10 updatedb
694 .fi
695 .if n \{\
696 .RE
697 .\}
698 .PP
699 This command invokes the
700 \fBupdatedb\fR(8)
701 tool, but lowers the block I/O weight for it to 10\&. See
702 \fBsystemd.resource-control\fR(5)
703 for more information on the
704 \fIIOWeight=\fR
705 property\&.
706 .PP
707 \fBExample\ \&3.\ \&Running commands at a specified time\fR
708 .PP
709 The following command will touch a file after 30 seconds\&.
710 .sp
711 .if n \{\
712 .RS 4
713 .\}
714 .nf
715 # date; systemd\-run \-\-on\-active=30 \-\-timer\-property=AccuracySec=100ms /bin/touch /tmp/foo
716 Mon Dec 8 20:44:24 KST 2014
717 Running as unit: run\-71\&.timer
718 Will run service as unit: run\-71\&.service
719 # journalctl \-b \-u run\-71\&.timer
720 \-\- Journal begins at Fri 2014\-12\-05 19:09:21 KST, ends at Mon 2014\-12\-08 20:44:54 KST\&. \-\-
721 Dec 08 20:44:38 container systemd[1]: Starting /bin/touch /tmp/foo\&.
722 Dec 08 20:44:38 container systemd[1]: Started /bin/touch /tmp/foo\&.
723 # journalctl \-b \-u run\-71\&.service
724 \-\- Journal begins at Fri 2014\-12\-05 19:09:21 KST, ends at Mon 2014\-12\-08 20:44:54 KST\&. \-\-
725 Dec 08 20:44:48 container systemd[1]: Starting /bin/touch /tmp/foo\&.\&.\&.
726 Dec 08 20:44:48 container systemd[1]: Started /bin/touch /tmp/foo\&.
727 .fi
728 .if n \{\
729 .RE
730 .\}
731 .PP
732 \fBExample\ \&4.\ \&Allowing access to the tty\fR
733 .PP
734 The following command invokes
735 \fBbash\fR(1)
736 as a service passing its standard input, output and error to the calling TTY\&.
737 .sp
738 .if n \{\
739 .RS 4
740 .\}
741 .nf
742 # systemd\-run \-t \-\-send\-sighup bash
743 .fi
744 .if n \{\
745 .RE
746 .\}
747 .PP
748 \fBExample\ \&5.\ \&Start screen as a user service\fR
749 .sp
750 .if n \{\
751 .RS 4
752 .\}
753 .nf
754 $ systemd\-run \-\-scope \-\-user screen
755 Running scope as unit run\-r14b0047ab6df45bfb45e7786cc839e76\&.scope\&.
756
757 $ screen \-ls
758 There is a screen on:
759 492\&.\&.laptop (Detached)
760 1 Socket in /var/run/screen/S\-fatima\&.
761 .fi
762 .if n \{\
763 .RE
764 .\}
765 .PP
766 This starts the
767 \fBscreen\fR
768 process as a child of the
769 \fBsystemd \-\-user\fR
770 process that was started by
771 user@\&.service, in a scope unit\&. A
772 \fBsystemd.scope\fR(5)
773 unit is used instead of a
774 \fBsystemd.service\fR(5)
775 unit, because
776 \fBscreen\fR
777 will exit when detaching from the terminal, and a service unit would be terminated\&. Running
778 \fBscreen\fR
779 as a user unit has the advantage that it is not part of the session scope\&. If
780 \fIKillUserProcesses=yes\fR
781 is configured in
782 \fBlogind.conf\fR(5), the default, the session scope will be terminated when the user logs out of that session\&.
783 .PP
784 The
785 user@\&.service
786 is started automatically when the user first logs in, and stays around as long as at least one login session is open\&. After the user logs out of the last session,
787 user@\&.service
788 and all services underneath it are terminated\&. This behavior is the default, when "lingering" is not enabled for that user\&. Enabling lingering means that
789 user@\&.service
790 is started automatically during boot, even if the user is not logged in, and that the service is not terminated when the user logs out\&.
791 .PP
792 Enabling lingering allows the user to run processes without being logged in, for example to allow
793 \fBscreen\fR
794 to persist after the user logs out, even if the session scope is terminated\&. In the default configuration, users can enable lingering for themselves:
795 .sp
796 .if n \{\
797 .RS 4
798 .\}
799 .nf
800 $ loginctl enable\-linger
801 .fi
802 .if n \{\
803 .RE
804 .\}
805 .PP
806 \fBExample\ \&6.\ \&Variable expansion by the manager\fR
807 .sp
808 .if n \{\
809 .RS 4
810 .\}
811 .nf
812 $ systemd\-run \-t echo "<${INVOCATION_ID}>" \*(Aq<${INVOCATION_ID}>\*(Aq
813 <> <5d0149bfa2c34b79bccb13074001eb20>
814 .fi
815 .if n \{\
816 .RE
817 .\}
818 .PP
819 The first argument is expanded by the shell (double quotes), but the second one is not expanded by the shell (single quotes)\&.
820 \fBecho\fR(1)
821 is called with ["/usr/bin/echo",
822 "<>",
823 "<${INVOCATION_ID}>"] as the argument array, and then
824 \fBsystemd\fR(1)
825 generates
826 \fI${INVOCATION_ID}\fR
827 and substitutes it in the command\-line\&. This substitution could not be done on the client side, because the target ID that will be set for the service is not known before the call is made\&.
828 .PP
829 \fBExample\ \&7.\ \&Variable expansion and output redirection using a shell\fR
830 .PP
831 Variable expansion by
832 \fBsystemd\fR(1)
833 can be disabled with
834 \fI\-\-expand\-environment=no\fR\&.
835 .PP
836 Disabling variable expansion can be useful if the command to execute contains dollar characters and escaping them would be inconvenient\&. For example, when a shell is used:
837 .sp
838 .if n \{\
839 .RS 4
840 .\}
841 .nf
842 $ systemd\-run \-\-expand\-environment=no \-t bash \e
843 \-c \*(Aqecho $SHELL $$ >/dev/stdout\*(Aq
844 /bin/bash 12345
845 .fi
846 .if n \{\
847 .RE
848 .\}
849 .PP
850 The last argument is passed verbatim to the
851 \fBbash\fR(1)
852 shell which is started by the service unit\&. The shell expands
853 "$SHELL"
854 to the path of the shell, and
855 "$$"
856 to its process number, and then those strings are passed to the
857 \fBecho\fR
858 built\-in and printed to standard output (which, in this case, is connected to the calling terminal)\&.
859 .PP
860 \fBExample\ \&8.\ \&Return value\fR
861 .sp
862 .if n \{\
863 .RS 4
864 .\}
865 .nf
866 $ systemd\-run \-\-user \-\-wait true
867 $ systemd\-run \-\-user \-\-wait \-p SuccessExitStatus=11 bash \-c \*(Aqexit 11\*(Aq
868 $ systemd\-run \-\-user \-\-wait \-p SuccessExitStatus=SIGUSR1 \-\-expand\-environment=no \e
869 bash \-c \*(Aqkill \-SIGUSR1 $$\*(Aq
870 .fi
871 .if n \{\
872 .RE
873 .\}
874 .PP
875 Those three invocations will succeed, i\&.e\&. terminate with an exit code of 0\&.
876 .SH "SEE ALSO"
877 .PP
878 \fBsystemd\fR(1), \fBsystemctl\fR(1), \fBsystemd.unit\fR(5), \fBsystemd.service\fR(5), \fBsystemd.scope\fR(5), \fBsystemd.slice\fR(5), \fBsystemd.exec\fR(5), \fBsystemd.resource-control\fR(5), \fBsystemd.timer\fR(5), \fBsystemd-mount\fR(1), \fBmachinectl\fR(1), \fBrun0\fR(1)
879 .SH "NOTES"
880 .IP " 1." 4
881 ANSI Escape Code (Wikipedia)
882 .RS 4
883 \%https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
884 .RE