]>
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>--scope</option></term> | |
94 | ||
95 | <listitem> | |
3803cde4 | 96 | <para>Create a transient <filename>.scope</filename> unit instead of |
f09114bc ZJS |
97 | the default transient <filename>.service</filename> unit. |
98 | </para> | |
99 | </listitem> | |
100 | </varlistentry> | |
101 | ||
102 | <varlistentry> | |
103 | <term><option>--unit=</option></term> | |
104 | ||
105 | <listitem><para>Use this unit name instead of an automatically | |
106 | generated one.</para></listitem> | |
107 | </varlistentry> | |
108 | ||
df31a6c0 LP |
109 | <varlistentry> |
110 | <term><option>--property=</option></term> | |
111 | <term><option>-p</option></term> | |
112 | ||
113 | <listitem><para>Sets a unit property for the scope or service | |
114 | unit that is created. This takes an assignment in the same | |
115 | format as | |
116 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
117 | <command>set-property</command> command.</para> | |
118 | </listitem> | |
119 | </varlistentry> | |
120 | ||
f09114bc ZJS |
121 | <varlistentry> |
122 | <term><option>--description=</option></term> | |
123 | ||
dca348bc | 124 | <listitem><para>Provide a description for the service or scope |
981ee551 | 125 | unit. If not specified, the command itself will be used as a |
b8bde116 | 126 | description. See <varname>Description=</varname> in |
f09114bc ZJS |
127 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
128 | </para></listitem> | |
129 | </varlistentry> | |
130 | ||
131 | <varlistentry> | |
132 | <term><option>--slice=</option></term> | |
133 | ||
134 | <listitem><para>Make the new <filename>.service</filename> or | |
135 | <filename>.scope</filename> unit part of the specified slice, | |
136 | instead of the <filename>system.slice</filename>.</para> | |
137 | </listitem> | |
138 | </varlistentry> | |
6577c7ce LP |
139 | |
140 | <varlistentry> | |
141 | <term><option>--remain-after-exit</option></term> | |
142 | ||
981ee551 LP |
143 | <listitem><para>After the service or scope process has |
144 | terminated, keep the service around until it is explicitly | |
145 | stopped. This is useful to collect runtime information about | |
146 | the service after it finished running. Also see | |
6577c7ce LP |
147 | <varname>RemainAfterExit=</varname> in |
148 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
149 | </para> | |
150 | </listitem> | |
151 | </varlistentry> | |
a6c0353b LP |
152 | |
153 | <varlistentry> | |
154 | <term><option>--send-sighup</option></term> | |
155 | ||
981ee551 LP |
156 | <listitem><para>When terminating the scope or service unit, |
157 | send a SIGHUP immediately after SIGTERM. This is useful to | |
158 | indicate to shells and shell-like processes that the | |
159 | connection has been severed. Also see | |
160 | <varname>SendSIGHUP=</varname> in | |
a6c0353b LP |
161 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
162 | </para> | |
163 | </listitem> | |
164 | </varlistentry> | |
dfdebb1b | 165 | |
981ee551 LP |
166 | <varlistentry> |
167 | <term><option>--service-type=</option></term> | |
168 | ||
169 | <listitem><para>Sets the service type. Also see | |
170 | <varname>Type=</varname> in | |
171 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>. This | |
172 | option has no effect in conjunction with | |
173 | <option>--scope</option>. Defaults to | |
174 | <constant>simple</constant>.</para> | |
175 | </listitem> | |
176 | </varlistentry> | |
177 | ||
178 | <varlistentry> | |
179 | <term><option>--uid=</option></term> | |
180 | <term><option>--gid=</option></term> | |
181 | ||
182 | <listitem><para>Runs the service process under the UNIX user | |
183 | and group. Also see <varname>User=</varname> and | |
184 | <varname>Group=</varname> in | |
4de33e7f | 185 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
981ee551 LP |
186 | </listitem> |
187 | </varlistentry> | |
188 | ||
189 | <varlistentry> | |
190 | <term><option>--nice=</option></term> | |
191 | ||
192 | <listitem><para>Runs the service process with the specified | |
193 | nice level. Also see <varname>Nice=</varname> in | |
4de33e7f | 194 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
981ee551 LP |
195 | </listitem> |
196 | </varlistentry> | |
197 | ||
198 | <varlistentry> | |
199 | <term><option>--setenv=</option></term> | |
200 | ||
201 | <listitem><para>Runs the service process with the specified | |
202 | environment variables set. Also see | |
203 | <varname>Environment=</varname> in | |
4de33e7f | 204 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
981ee551 LP |
205 | </listitem> |
206 | </varlistentry> | |
207 | ||
88ae7333 ZJS |
208 | <xi:include href="user-system-options.xml" xpointer="user" /> |
209 | <xi:include href="user-system-options.xml" xpointer="system" /> | |
4f50d2ef ZJS |
210 | <xi:include href="user-system-options.xml" xpointer="host" /> |
211 | <xi:include href="user-system-options.xml" xpointer="machine" /> | |
88ae7333 | 212 | |
dfdebb1b ZJS |
213 | <xi:include href="standard-options.xml" xpointer="help" /> |
214 | <xi:include href="standard-options.xml" xpointer="version" /> | |
f09114bc ZJS |
215 | </variablelist> |
216 | ||
217 | <para>All command-line arguments after the first non-option | |
3f85ef0f | 218 | argument become part of the command line of the launched |
fbce1139 | 219 | process. If a command is run as service unit, its first argument |
3803cde4 | 220 | needs to be an absolute binary path.</para> |
f09114bc ZJS |
221 | </refsect1> |
222 | ||
223 | <refsect1> | |
224 | <title>Exit status</title> | |
225 | ||
226 | <para>On success, 0 is returned, a non-zero failure | |
227 | code otherwise.</para> | |
228 | </refsect1> | |
229 | ||
c9d954b2 | 230 | <refsect1> |
df31a6c0 | 231 | <title>Examples</title> |
c9d954b2 ZJS |
232 | |
233 | <para>The following command will log the environment variables | |
234 | provided by systemd to services:</para> | |
235 | ||
236 | <programlisting># systemd-run env | |
237 | Running as unit run-19945.service. | |
238 | # journalctl -u run-19945.service | |
239 | Sep 08 07:37:21 bupkis systemd[1]: Starting /usr/bin/env... | |
240 | Sep 08 07:37:21 bupkis systemd[1]: Started /usr/bin/env. | |
241 | Sep 08 07:37:21 bupkis env[19948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin | |
242 | Sep 08 07:37:21 bupkis env[19948]: LANG=en_US.UTF-8 | |
9fccdb0f | 243 | Sep 08 07:37:21 bupkis env[19948]: BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.x86_64</programlisting> |
df31a6c0 LP |
244 | |
245 | <para>The following command invokes the | |
5aded369 | 246 | <citerefentry project='man-pages'><refentrytitle>updatedb</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
b8bde116 | 247 | tool, but lowers the block IO weight for it to 10. See |
df31a6c0 LP |
248 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
249 | for more information on the <varname>BlockIOWeight=</varname> | |
250 | property.</para> | |
251 | ||
252 | <programlisting># systemd-run -p BlockIOWeight=10 updatedb</programlisting> | |
c9d954b2 ZJS |
253 | </refsect1> |
254 | ||
f09114bc ZJS |
255 | <refsect1> |
256 | <title>See Also</title> | |
257 | <para> | |
258 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
3803cde4 | 259 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
f09114bc ZJS |
260 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
261 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
262 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
d21ed1ea | 263 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
df31a6c0 LP |
264 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
265 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
d21ed1ea | 266 | <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
f09114bc ZJS |
267 | </para> |
268 | </refsect1> | |
269 | ||
270 | </refentry> |