]>
Commit | Line | Data |
---|---|---|
3802a3d3 | 1 | <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*--> |
f09114bc | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
12b42c76 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
f09114bc ZJS |
4 | |
5 | <!-- | |
b975b0d5 | 6 | This file is part of systemd. |
f09114bc | 7 | |
b975b0d5 | 8 | Copyright 2013 Zbigniew Jędrzejewski-Szmek |
f09114bc | 9 | |
b975b0d5 ZJS |
10 | systemd is free software; you can redistribute it and/or modify it |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
f09114bc | 14 | |
b975b0d5 ZJS |
15 | systemd is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
f09114bc | 19 | |
b975b0d5 ZJS |
20 | You should have received a copy of the GNU Lesser General Public License |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
f09114bc ZJS |
22 | --> |
23 | ||
dfdebb1b ZJS |
24 | <refentry id="systemd-run" |
25 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
f09114bc ZJS |
26 | |
27 | <refentryinfo> | |
28 | <title>systemd-run</title> | |
29 | <productname>systemd</productname> | |
30 | ||
31 | <authorgroup> | |
32 | <author> | |
33 | <contrib>Developer</contrib> | |
34 | <firstname>Lennart</firstname> | |
35 | <surname>Poettering</surname> | |
36 | <email>lennart@poettering.net</email> | |
37 | </author> | |
38 | </authorgroup> | |
39 | </refentryinfo> | |
40 | ||
41 | <refmeta> | |
42 | <refentrytitle>systemd-run</refentrytitle> | |
43 | <manvolnum>1</manvolnum> | |
44 | </refmeta> | |
45 | ||
46 | <refnamediv> | |
47 | <refname>systemd-run</refname> | |
4c213d6c | 48 | <refpurpose>Run programs in transient scope or service or timer units</refpurpose> |
f09114bc ZJS |
49 | </refnamediv> |
50 | ||
51 | <refsynopsisdiv> | |
52 | <cmdsynopsis> | |
53 | <command>systemd-run</command> | |
54 | <arg choice="opt" rep="repeat">OPTIONS</arg> | |
55 | <arg choice="plain"><replaceable>COMMAND</replaceable> | |
56 | <arg choice="opt" rep="repeat">ARGS</arg> | |
57 | </arg> | |
58 | </cmdsynopsis> | |
4c213d6c WC |
59 | <cmdsynopsis> |
60 | <command>systemd-run</command> | |
61 | <arg choice="opt" rep="repeat">OPTIONS</arg> | |
62 | <arg choice="opt" rep="repeat">TIMER OPTIONS</arg> | |
63 | <arg choice="req"><replaceable>COMMAND</replaceable></arg> | |
64 | <arg choice="opt" rep="repeat">ARGS</arg> | |
65 | </cmdsynopsis> | |
f09114bc ZJS |
66 | </refsynopsisdiv> |
67 | ||
68 | <refsect1> | |
69 | <title>Description</title> | |
70 | ||
4c213d6c | 71 | <para><command>systemd-run</command> may be used to create and |
dec896f8 LP |
72 | start a transient <filename>.service</filename> or |
73 | <filename>.scope</filename> unit and run the specified | |
74 | <replaceable>COMMAND</replaceable> in it. It may also be used to | |
75 | create and start transient <filename>.timer</filename> | |
76 | units.</para> | |
3803cde4 LP |
77 | |
78 | <para>If a command is run as transient service unit, it will be | |
79 | started and managed by the service manager like any other service, | |
dec896f8 | 80 | and thus shows up in the output of <command>systemctl |
3803cde4 | 81 | list-units</command> like any other unit. It will run in a clean |
dec896f8 LP |
82 | and detached execution environment, with the service manager as |
83 | its parent process. In this mode <command>systemd-run</command> | |
84 | will start the service asynchronously in the background and return | |
85 | after the command has begun execution.</para> | |
4c213d6c | 86 | |
3803cde4 | 87 | <para>If a command is run as transient scope unit, it will be |
dec896f8 LP |
88 | started by <command>systemd-run</command> itself as parent process |
89 | and will thus inherit the execution environment of the | |
90 | caller. However, the processes of the command are managed by the | |
91 | service manager similar to normal services, and will show up in | |
92 | the output of <command>systemctl list-units</command>. Execution | |
93 | in this case is synchronous, and will return only when the command | |
94 | finishes. This mode is enabled via the <option>--scope</option> | |
95 | switch (see below). </para> | |
96 | ||
97 | <para>If a command is run with timer options such as | |
98 | <option>--on-calendar=</option> (see below), a transient timer | |
99 | unit is created alongside the service unit for the specified | |
100 | command. Only the transient timer unit is started immediately, the | |
101 | transient service unit will be started when the transient timer | |
102 | elapses. If the <option>--unit=</option> is specified, the | |
103 | <replaceable>COMMAND</replaceable> may be omitted. In this case, | |
104 | <command>systemd-run</command> only creates a | |
105 | <filename>.timer</filename> unit that invokes the specified unit | |
106 | when elapsing.</para> | |
f09114bc ZJS |
107 | </refsect1> |
108 | ||
109 | <refsect1> | |
110 | <title>Options</title> | |
111 | ||
112 | <para>The following options are understood:</para> | |
113 | ||
114 | <variablelist> | |
8c7db2fb EV |
115 | <varlistentry> |
116 | <term><option>--no-ask-password</option></term> | |
117 | ||
118 | <listitem><para>Do not query the user for authentication for | |
119 | privileged operations.</para></listitem> | |
120 | </varlistentry> | |
121 | ||
f09114bc ZJS |
122 | <varlistentry> |
123 | <term><option>--scope</option></term> | |
124 | ||
125 | <listitem> | |
3803cde4 | 126 | <para>Create a transient <filename>.scope</filename> unit instead of |
f09114bc ZJS |
127 | the default transient <filename>.service</filename> unit. |
128 | </para> | |
129 | </listitem> | |
130 | </varlistentry> | |
131 | ||
132 | <varlistentry> | |
133 | <term><option>--unit=</option></term> | |
134 | ||
135 | <listitem><para>Use this unit name instead of an automatically | |
136 | generated one.</para></listitem> | |
137 | </varlistentry> | |
138 | ||
df31a6c0 LP |
139 | <varlistentry> |
140 | <term><option>--property=</option></term> | |
141 | <term><option>-p</option></term> | |
142 | ||
143 | <listitem><para>Sets a unit property for the scope or service | |
144 | unit that is created. This takes an assignment in the same | |
145 | format as | |
146 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
147 | <command>set-property</command> command.</para> | |
148 | </listitem> | |
149 | </varlistentry> | |
150 | ||
f09114bc ZJS |
151 | <varlistentry> |
152 | <term><option>--description=</option></term> | |
153 | ||
dca348bc | 154 | <listitem><para>Provide a description for the service or scope |
981ee551 | 155 | unit. If not specified, the command itself will be used as a |
b8bde116 | 156 | description. See <varname>Description=</varname> in |
f09114bc ZJS |
157 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
158 | </para></listitem> | |
159 | </varlistentry> | |
160 | ||
161 | <varlistentry> | |
162 | <term><option>--slice=</option></term> | |
163 | ||
164 | <listitem><para>Make the new <filename>.service</filename> or | |
165 | <filename>.scope</filename> unit part of the specified slice, | |
166 | instead of the <filename>system.slice</filename>.</para> | |
167 | </listitem> | |
168 | </varlistentry> | |
6577c7ce LP |
169 | |
170 | <varlistentry> | |
171 | <term><option>--remain-after-exit</option></term> | |
172 | ||
981ee551 LP |
173 | <listitem><para>After the service or scope process has |
174 | terminated, keep the service around until it is explicitly | |
175 | stopped. This is useful to collect runtime information about | |
176 | the service after it finished running. Also see | |
6577c7ce LP |
177 | <varname>RemainAfterExit=</varname> in |
178 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
179 | </para> | |
180 | </listitem> | |
181 | </varlistentry> | |
a6c0353b LP |
182 | |
183 | <varlistentry> | |
184 | <term><option>--send-sighup</option></term> | |
185 | ||
981ee551 LP |
186 | <listitem><para>When terminating the scope or service unit, |
187 | send a SIGHUP immediately after SIGTERM. This is useful to | |
188 | indicate to shells and shell-like processes that the | |
189 | connection has been severed. Also see | |
190 | <varname>SendSIGHUP=</varname> in | |
a6c0353b LP |
191 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
192 | </para> | |
193 | </listitem> | |
194 | </varlistentry> | |
dfdebb1b | 195 | |
981ee551 LP |
196 | <varlistentry> |
197 | <term><option>--service-type=</option></term> | |
198 | ||
199 | <listitem><para>Sets the service type. Also see | |
200 | <varname>Type=</varname> in | |
201 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>. This | |
202 | option has no effect in conjunction with | |
203 | <option>--scope</option>. Defaults to | |
204 | <constant>simple</constant>.</para> | |
205 | </listitem> | |
206 | </varlistentry> | |
207 | ||
208 | <varlistentry> | |
209 | <term><option>--uid=</option></term> | |
210 | <term><option>--gid=</option></term> | |
211 | ||
212 | <listitem><para>Runs the service process under the UNIX user | |
213 | and group. Also see <varname>User=</varname> and | |
214 | <varname>Group=</varname> in | |
4de33e7f | 215 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
981ee551 LP |
216 | </listitem> |
217 | </varlistentry> | |
218 | ||
219 | <varlistentry> | |
220 | <term><option>--nice=</option></term> | |
221 | ||
222 | <listitem><para>Runs the service process with the specified | |
223 | nice level. Also see <varname>Nice=</varname> in | |
4de33e7f | 224 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
981ee551 LP |
225 | </listitem> |
226 | </varlistentry> | |
227 | ||
228 | <varlistentry> | |
229 | <term><option>--setenv=</option></term> | |
230 | ||
231 | <listitem><para>Runs the service process with the specified | |
232 | environment variables set. Also see | |
233 | <varname>Environment=</varname> in | |
4de33e7f | 234 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
981ee551 LP |
235 | </listitem> |
236 | </varlistentry> | |
237 | ||
9b15b784 LP |
238 | <varlistentry> |
239 | <term><option>--pty</option></term> | |
240 | <term><option>-t</option></term> | |
241 | ||
242 | <listitem><para>When invoking a command as service connects | |
243 | its standard input and output to the invoking tty via a | |
244 | pseudo TTY device. This allows invoking binaries as services | |
095dc596 | 245 | that expect interactive user input, such as interactive |
9b15b784 LP |
246 | command shells.</para></listitem> |
247 | </varlistentry> | |
88ae7333 | 248 | |
095dc596 LP |
249 | <varlistentry> |
250 | <term><option>--quiet</option></term> | |
251 | <term><option>-q</option></term> | |
252 | ||
253 | <listitem><para>Suppresses additional informational output | |
254 | while running. This is particularly useful in combination with | |
255 | <option>--pty</option> when it will suppress the initial | |
256 | message explaining how to terminate the TTY connection.</para></listitem> | |
257 | </varlistentry> | |
258 | ||
4c213d6c WC |
259 | <varlistentry> |
260 | <term><option>--on-active=</option></term> | |
261 | <term><option>--on-boot=</option></term> | |
262 | <term><option>--on-startup=</option></term> | |
263 | <term><option>--on-unit-active=</option></term> | |
264 | <term><option>--on-unit-inactive=</option></term> | |
265 | ||
266 | <listitem><para>Defines monotonic timers relative to different | |
267 | starting points. Also see <varname>OnActiveSec=</varname>, | |
268 | <varname>OnBootSec=</varname>, | |
269 | <varname>OnStartupSec=</varname>, | |
270 | <varname>OnUnitActiveSec=</varname> and | |
271 | <varname>OnUnitInactiveSec=</varname> in | |
272 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>. This | |
273 | options have no effect in conjunction with | |
274 | <option>--scope</option>.</para> | |
275 | </listitem> | |
276 | </varlistentry> | |
277 | ||
278 | <varlistentry> | |
279 | <term><option>--on-calendar=</option></term> | |
280 | ||
281 | <listitem><para>Defines realtime (i.e. wallclock) timers with | |
282 | calendar event expressions. Also see | |
283 | <varname>OnCalendar=</varname> in | |
284 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>. This | |
285 | option has no effect in conjunction with | |
286 | <option>--scope</option>.</para> | |
287 | </listitem> | |
288 | </varlistentry> | |
289 | ||
290 | <varlistentry> | |
291 | <term><option>--timer-property=</option></term> | |
292 | ||
293 | <listitem><para>Sets a timer unit property for the timer unit | |
294 | that is created. It is similar with | |
295 | <option>--property</option> but only for created timer | |
296 | unit. This option only has effect in conjunction with | |
297 | <option>--on-active=</option>, <option>--on-boot=</option>, | |
298 | <option>--on-startup=</option>, | |
299 | <option>--on-unit-active=</option>, | |
300 | <option>--on-unit-inactive=</option>, | |
301 | <option>--on-calendar=</option>. This takes an assignment in | |
302 | the same format as | |
303 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
304 | <command>set-property</command> command.</para> </listitem> | |
305 | </varlistentry> | |
306 | ||
3d161f99 LP |
307 | <varlistentry> |
308 | <term><option>--no-block</option></term> | |
309 | ||
310 | <listitem> | |
311 | <para>Do not synchronously wait for the requested operation | |
312 | to finish. If this is not specified, the job will be | |
313 | verified, enqueued and <command>systemd-run</command> will | |
314 | wait until the unit's start-up is completed. By passing this | |
315 | argument, it is only verified and enqueued.</para> | |
316 | </listitem> | |
317 | </varlistentry> | |
318 | ||
9b15b784 LP |
319 | <xi:include href="user-system-options.xml" xpointer="user" /> |
320 | <xi:include href="user-system-options.xml" xpointer="system" /> | |
321 | <xi:include href="user-system-options.xml" xpointer="host" /> | |
322 | <xi:include href="user-system-options.xml" xpointer="machine" /> | |
323 | ||
dfdebb1b ZJS |
324 | <xi:include href="standard-options.xml" xpointer="help" /> |
325 | <xi:include href="standard-options.xml" xpointer="version" /> | |
f09114bc ZJS |
326 | </variablelist> |
327 | ||
81c7dd89 | 328 | <para>All command line arguments after the first non-option |
3f85ef0f | 329 | argument become part of the command line of the launched |
fbce1139 | 330 | process. If a command is run as service unit, its first argument |
3803cde4 | 331 | needs to be an absolute binary path.</para> |
f09114bc ZJS |
332 | </refsect1> |
333 | ||
334 | <refsect1> | |
335 | <title>Exit status</title> | |
336 | ||
337 | <para>On success, 0 is returned, a non-zero failure | |
338 | code otherwise.</para> | |
339 | </refsect1> | |
340 | ||
c9d954b2 | 341 | <refsect1> |
df31a6c0 | 342 | <title>Examples</title> |
c9d954b2 ZJS |
343 | |
344 | <para>The following command will log the environment variables | |
345 | provided by systemd to services:</para> | |
346 | ||
347 | <programlisting># systemd-run env | |
348 | Running as unit run-19945.service. | |
349 | # journalctl -u run-19945.service | |
350 | Sep 08 07:37:21 bupkis systemd[1]: Starting /usr/bin/env... | |
351 | Sep 08 07:37:21 bupkis systemd[1]: Started /usr/bin/env. | |
352 | Sep 08 07:37:21 bupkis env[19948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin | |
353 | Sep 08 07:37:21 bupkis env[19948]: LANG=en_US.UTF-8 | |
9fccdb0f | 354 | Sep 08 07:37:21 bupkis env[19948]: BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.x86_64</programlisting> |
df31a6c0 LP |
355 | |
356 | <para>The following command invokes the | |
5aded369 | 357 | <citerefentry project='man-pages'><refentrytitle>updatedb</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
b8bde116 | 358 | tool, but lowers the block IO weight for it to 10. See |
df31a6c0 LP |
359 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
360 | for more information on the <varname>BlockIOWeight=</varname> | |
361 | property.</para> | |
362 | ||
363 | <programlisting># systemd-run -p BlockIOWeight=10 updatedb</programlisting> | |
4c213d6c WC |
364 | |
365 | <para>The following command will touch a file after 30 seconds.</para> | |
366 | ||
367 | <programlisting># date; systemd-run --on-active=30 --timer-property=AccuracySec=100ms /bin/touch /tmp/foo | |
368 | Mon Dec 8 20:44:24 KST 2014 | |
369 | Running as unit run-71.timer. | |
370 | Will run as unit run-71.service. | |
85fb8031 | 371 | # journalctl -b -u run-71.timer |
4c213d6c WC |
372 | -- Logs begin at Fri 2014-12-05 19:09:21 KST, end at Mon 2014-12-08 20:44:54 KST. -- |
373 | Dec 08 20:44:38 container systemd[1]: Starting /bin/touch /tmp/foo. | |
374 | Dec 08 20:44:38 container systemd[1]: Started /bin/touch /tmp/foo. | |
85fb8031 | 375 | # journalctl -b -u run-71.service |
4c213d6c WC |
376 | -- Logs begin at Fri 2014-12-05 19:09:21 KST, end at Mon 2014-12-08 20:44:54 KST. -- |
377 | Dec 08 20:44:48 container systemd[1]: Starting /bin/touch /tmp/foo... | |
378 | Dec 08 20:44:48 container systemd[1]: Started /bin/touch /tmp/foo.</programlisting> | |
9b15b784 LP |
379 | |
380 | <para>The following command invokes <filename>/bin/bash</filename> | |
381 | as a service passing its standard input, output and error to | |
382 | the calling TTY.</para> | |
383 | ||
de6fae8a | 384 | <programlisting># systemd-run -t --send-sighup /bin/bash</programlisting> |
9b15b784 | 385 | |
c9d954b2 ZJS |
386 | </refsect1> |
387 | ||
f09114bc ZJS |
388 | <refsect1> |
389 | <title>See Also</title> | |
390 | <para> | |
391 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
3803cde4 | 392 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
f09114bc ZJS |
393 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
394 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
395 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
d21ed1ea | 396 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
df31a6c0 LP |
397 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
398 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
4c213d6c | 399 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
d21ed1ea | 400 | <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
f09114bc ZJS |
401 | </para> |
402 | </refsect1> | |
403 | ||
404 | </refentry> |