]>
Commit | Line | Data |
---|---|---|
f09114bc ZJS |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2013 Zbigniew Jędrzejewski-Szmek | |
9 | ||
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. | |
14 | ||
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. | |
19 | ||
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/>. | |
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> | |
3803cde4 | 48 | <refpurpose>Run programs in transient scope or service 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> | |
59 | </refsynopsisdiv> | |
60 | ||
61 | <refsect1> | |
62 | <title>Description</title> | |
63 | ||
2614202b | 64 | <para><command>systemd-run</command> may be used to create and start |
3803cde4 LP |
65 | a transient <filename>.service</filename> or a |
66 | <filename>.scope</filename> unit and run the specified | |
67 | <replaceable>COMMAND</replaceable> in it.</para> | |
68 | ||
69 | <para>If a command is run as transient service unit, it will be | |
70 | started and managed by the service manager like any other service, | |
71 | and thus show up in the output of <command>systemctl | |
72 | list-units</command> like any other unit. It will run in a clean | |
73 | and detached execution environment. <command>systemd-run</command> | |
74 | will start the service asynchronously in the background and | |
75 | immediately return.</para> | |
76 | ||
77 | <para>If a command is run as transient scope unit, it will be | |
78 | started directly by <command>systemd-run</command> and thus | |
79 | inherit the execution environment of the caller. It is however | |
80 | managed by the service manager similar to normal services, and | |
81 | will also show up in the output of <command>systemctl | |
82 | list-units</command>. Execution in this case is synchronous, and | |
83 | execution will return only when the command finishes.</para> | |
f09114bc ZJS |
84 | </refsect1> |
85 | ||
86 | <refsect1> | |
87 | <title>Options</title> | |
88 | ||
89 | <para>The following options are understood:</para> | |
90 | ||
91 | <variablelist> | |
f09114bc ZJS |
92 | <varlistentry> |
93 | <term><option>--user</option></term> | |
94 | ||
95 | <listitem> | |
3803cde4 LP |
96 | <para>Talk to the service manager of the calling user, |
97 | rather than the service manager of the system.</para> | |
f09114bc ZJS |
98 | </listitem> |
99 | </varlistentry> | |
100 | ||
66b1e746 LP |
101 | <varlistentry> |
102 | <term><option>--system</option></term> | |
103 | ||
104 | <listitem> | |
105 | <para>Talk to the service manager of the system. This is the | |
106 | implied default.</para> | |
107 | </listitem> | |
108 | </varlistentry> | |
109 | ||
d21ed1ea LP |
110 | <varlistentry> |
111 | <term><option>-H</option></term> | |
112 | <term><option>--host=</option></term> | |
113 | ||
63ba209d | 114 | <listitem><para>Execute the operation |
d21ed1ea LP |
115 | remotely. Specify a hostname, or |
116 | username and hostname separated by <literal>@</literal>, | |
117 | to connect to. This will use SSH to | |
118 | talk to the remote machine manager | |
119 | instance.</para></listitem> | |
120 | </varlistentry> | |
121 | ||
122 | <varlistentry> | |
123 | <term><option>-M</option></term> | |
124 | <term><option>--machine=</option></term> | |
125 | ||
63ba209d | 126 | <listitem><para>Execute the operation on a |
d21ed1ea LP |
127 | local container. Specify a container |
128 | name to connect to.</para></listitem> | |
129 | </varlistentry> | |
130 | ||
f09114bc ZJS |
131 | <varlistentry> |
132 | <term><option>--scope</option></term> | |
133 | ||
134 | <listitem> | |
3803cde4 | 135 | <para>Create a transient <filename>.scope</filename> unit instead of |
f09114bc ZJS |
136 | the default transient <filename>.service</filename> unit. |
137 | </para> | |
138 | </listitem> | |
139 | </varlistentry> | |
140 | ||
141 | <varlistentry> | |
142 | <term><option>--unit=</option></term> | |
143 | ||
144 | <listitem><para>Use this unit name instead of an automatically | |
145 | generated one.</para></listitem> | |
146 | </varlistentry> | |
147 | ||
148 | <varlistentry> | |
149 | <term><option>--description=</option></term> | |
150 | ||
151 | <listitem><para>Provide description for the unit. If not | |
152 | specified, the command itself will be used as a description. | |
153 | See <varname>Description=</varname> in | |
154 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
155 | </para></listitem> | |
156 | </varlistentry> | |
157 | ||
158 | <varlistentry> | |
159 | <term><option>--slice=</option></term> | |
160 | ||
161 | <listitem><para>Make the new <filename>.service</filename> or | |
162 | <filename>.scope</filename> unit part of the specified slice, | |
163 | instead of the <filename>system.slice</filename>.</para> | |
164 | </listitem> | |
165 | </varlistentry> | |
6577c7ce LP |
166 | |
167 | <varlistentry> | |
168 | <term><option>--remain-after-exit</option></term> | |
169 | ||
d6ee7fa2 | 170 | <listitem><para>After the service's process has terminated, keep |
6577c7ce LP |
171 | the service around until it is explicitly stopped. This is |
172 | useful to collect runtime information about the service after | |
173 | it finished running. Also see | |
174 | <varname>RemainAfterExit=</varname> in | |
175 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
176 | </para> | |
177 | </listitem> | |
178 | </varlistentry> | |
a6c0353b LP |
179 | |
180 | <varlistentry> | |
181 | <term><option>--send-sighup</option></term> | |
182 | ||
d6ee7fa2 | 183 | <listitem><para>When terminating the scope unit, send a SIGHUP |
a6c0353b LP |
184 | immediately after SIGTERM. This is useful to indicate to |
185 | shells and shell-like processes that the connection has been | |
d6ee7fa2 | 186 | severed. Also see <varname>SendSIGHUP=</varname> in |
a6c0353b LP |
187 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
188 | </para> | |
189 | </listitem> | |
190 | </varlistentry> | |
dfdebb1b ZJS |
191 | |
192 | <xi:include href="standard-options.xml" xpointer="help" /> | |
193 | <xi:include href="standard-options.xml" xpointer="version" /> | |
f09114bc ZJS |
194 | </variablelist> |
195 | ||
196 | <para>All command-line arguments after the first non-option | |
197 | argument become part of the commandline of the launched | |
fbce1139 | 198 | process. If a command is run as service unit, its first argument |
3803cde4 | 199 | needs to be an absolute binary path.</para> |
f09114bc ZJS |
200 | </refsect1> |
201 | ||
202 | <refsect1> | |
203 | <title>Exit status</title> | |
204 | ||
205 | <para>On success, 0 is returned, a non-zero failure | |
206 | code otherwise.</para> | |
207 | </refsect1> | |
208 | ||
c9d954b2 ZJS |
209 | <refsect1> |
210 | <title>Example</title> | |
211 | ||
212 | <para>The following command will log the environment variables | |
213 | provided by systemd to services:</para> | |
214 | ||
215 | <programlisting># systemd-run env | |
216 | Running as unit run-19945.service. | |
217 | # journalctl -u run-19945.service | |
218 | Sep 08 07:37:21 bupkis systemd[1]: Starting /usr/bin/env... | |
219 | Sep 08 07:37:21 bupkis systemd[1]: Started /usr/bin/env. | |
220 | Sep 08 07:37:21 bupkis env[19948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin | |
221 | Sep 08 07:37:21 bupkis env[19948]: LANG=en_US.UTF-8 | |
9fccdb0f | 222 | Sep 08 07:37:21 bupkis env[19948]: BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.x86_64</programlisting> |
c9d954b2 ZJS |
223 | </refsect1> |
224 | ||
f09114bc ZJS |
225 | <refsect1> |
226 | <title>See Also</title> | |
227 | <para> | |
228 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
3803cde4 | 229 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
f09114bc ZJS |
230 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
231 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
232 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
d21ed1ea LP |
233 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
234 | <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
f09114bc ZJS |
235 | </para> |
236 | </refsect1> | |
237 | ||
238 | </refentry> |