]> git.proxmox.com Git - systemd.git/blob - man/systemd-run.html
Imported Upstream version 218
[systemd.git] / man / systemd-run.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>systemd-run</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
2 a.headerlink {
3 color: #c60f0f;
4 font-size: 0.8em;
5 padding: 0 4px 0 4px;
6 text-decoration: none;
7 visibility: hidden;
8 }
9
10 a.headerlink:hover {
11 background-color: #c60f0f;
12 color: white;
13 }
14
15 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
16 visibility: visible;
17 }
18 </style><a href="index.html">Index </a>·
19 <a href="systemd.directives.html">Directives </a>·
20 <a href="../python-systemd/index.html">Python </a>·
21 <a href="../libudev/index.html">libudev </a>·
22 <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 218</span><hr><div class="refentry"><a name="systemd-run"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>systemd-run — Run programs in transient scope or service or timer units</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">systemd-run</code> [OPTIONS...] <em class="replaceable"><code>COMMAND</code></em>
23 [ARGS...]
24 </p></div><div class="cmdsynopsis"><p><code class="command">systemd-run</code> [OPTIONS...] [TIMER OPTIONS...] {<em class="replaceable"><code>COMMAND</code></em>} [ARGS...]</p></div></div><div class="refsect1"><a name="idm140717671223840"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p><span class="command"><strong>systemd-run</strong></span> may be used to create and
25 start a transient <code class="filename">.service</code> or a transient
26 <code class="filename">.timer</code> or a <code class="filename">.scope</code> unit
27 and run the specified <em class="replaceable"><code>COMMAND</code></em> in
28 it.</p><p>If a command is run as transient service unit, it will be
29 started and managed by the service manager like any other service,
30 and thus show up in the output of <span class="command"><strong>systemctl
31 list-units</strong></span> like any other unit. It will run in a clean
32 and detached execution environment. <span class="command"><strong>systemd-run</strong></span>
33 will start the service asynchronously in the background and
34 immediately return.</p><p>If a command is run with timer options, transient timer unit
35 also be created with transient service unit. But the transient
36 timer unit is only started immediately. The transient service unit
37 will be started when the transient timer is elapsed. If
38 <code class="option">--unit=</code> is specified with timer options, the
39 <em class="replaceable"><code>COMMAND</code></em> can be omitted. In this case,
40 <span class="command"><strong>systemd-run</strong></span> assumes service unit is already
41 loaded and creates transient timer unit only. To successfully
42 create timer unit, already loaded service unit should be specified
43 with <code class="option">--unit=</code>. This transient timer unit can
44 activate the existing service unit like any other timer.</p><p>If a command is run as transient scope unit, it will be
45 started directly by <span class="command"><strong>systemd-run</strong></span> and thus
46 inherit the execution environment of the caller. It is however
47 managed by the service manager similar to normal services, and
48 will also show up in the output of <span class="command"><strong>systemctl
49 list-units</strong></span>. Execution in this case is synchronous, and
50 execution will return only when the command finishes.</p></div><div class="refsect1"><a name="idm140717675112112"></a><h2 id="Options">Options<a class="headerlink" title="Permalink to this headline" href="#Options"></a></h2><p>The following options are understood:</p><div class="variablelist"><dl class="variablelist"><dt id="--scope"><span class="term"><code class="option">--scope</code></span><a class="headerlink" title="Permalink to this term" href="#--scope"></a></dt><dd><p>Create a transient <code class="filename">.scope</code> unit instead of
51 the default transient <code class="filename">.service</code> unit.
52 </p></dd><dt id="--unit="><span class="term"><code class="option">--unit=</code></span><a class="headerlink" title="Permalink to this term" href="#--unit="></a></dt><dd><p>Use this unit name instead of an automatically
53 generated one.</p></dd><dt id="--property="><span class="term"><code class="option">--property=</code>, </span><span class="term"><code class="option">-p</code></span><a class="headerlink" title="Permalink to this term" href="#--property="></a></dt><dd><p>Sets a unit property for the scope or service
54 unit that is created. This takes an assignment in the same
55 format as
56 <a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>'s
57 <span class="command"><strong>set-property</strong></span> command.</p></dd><dt id="--description="><span class="term"><code class="option">--description=</code></span><a class="headerlink" title="Permalink to this term" href="#--description="></a></dt><dd><p>Provide a description for the service or scope
58 unit. If not specified, the command itself will be used as a
59 description. See <code class="varname">Description=</code> in
60 <a href="systemd.unit.html"><span class="citerefentry"><span class="refentrytitle">systemd.unit</span>(5)</span></a>.
61 </p></dd><dt id="--slice="><span class="term"><code class="option">--slice=</code></span><a class="headerlink" title="Permalink to this term" href="#--slice="></a></dt><dd><p>Make the new <code class="filename">.service</code> or
62 <code class="filename">.scope</code> unit part of the specified slice,
63 instead of the <code class="filename">system.slice</code>.</p></dd><dt id="--remain-after-exit"><span class="term"><code class="option">--remain-after-exit</code></span><a class="headerlink" title="Permalink to this term" href="#--remain-after-exit"></a></dt><dd><p>After the service or scope process has
64 terminated, keep the service around until it is explicitly
65 stopped. This is useful to collect runtime information about
66 the service after it finished running. Also see
67 <code class="varname">RemainAfterExit=</code> in
68 <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>.
69 </p></dd><dt id="--send-sighup"><span class="term"><code class="option">--send-sighup</code></span><a class="headerlink" title="Permalink to this term" href="#--send-sighup"></a></dt><dd><p>When terminating the scope or service unit,
70 send a SIGHUP immediately after SIGTERM. This is useful to
71 indicate to shells and shell-like processes that the
72 connection has been severed. Also see
73 <code class="varname">SendSIGHUP=</code> in
74 <a href="systemd.kill.html"><span class="citerefentry"><span class="refentrytitle">systemd.kill</span>(5)</span></a>.
75 </p></dd><dt id="--service-type="><span class="term"><code class="option">--service-type=</code></span><a class="headerlink" title="Permalink to this term" href="#--service-type="></a></dt><dd><p>Sets the service type. Also see
76 <code class="varname">Type=</code> in
77 <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>. This
78 option has no effect in conjunction with
79 <code class="option">--scope</code>. Defaults to
80 <code class="constant">simple</code>.</p></dd><dt id="--uid="><span class="term"><code class="option">--uid=</code>, </span><span class="term"><code class="option">--gid=</code></span><a class="headerlink" title="Permalink to this term" href="#--uid="></a></dt><dd><p>Runs the service process under the UNIX user
81 and group. Also see <code class="varname">User=</code> and
82 <code class="varname">Group=</code> in
83 <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>.</p></dd><dt id="--nice="><span class="term"><code class="option">--nice=</code></span><a class="headerlink" title="Permalink to this term" href="#--nice="></a></dt><dd><p>Runs the service process with the specified
84 nice level. Also see <code class="varname">Nice=</code> in
85 <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>.</p></dd><dt id="--setenv="><span class="term"><code class="option">--setenv=</code></span><a class="headerlink" title="Permalink to this term" href="#--setenv="></a></dt><dd><p>Runs the service process with the specified
86 environment variables set. Also see
87 <code class="varname">Environment=</code> in
88 <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>.</p></dd><dt id="--user"><span class="term"><code class="option">--user</code></span><a class="headerlink" title="Permalink to this term" href="#--user"></a></dt><dd><p><a name="user-text"></a>Talk to the service manager of the calling user,
89 rather than the service manager of the system.</p></dd><dt id="--system"><span class="term"><code class="option">--system</code></span><a class="headerlink" title="Permalink to this term" href="#--system"></a></dt><dd><p><a name="system-text"></a>Talk to the service manager of the system. This is the
90 implied default.</p></dd><dt id="-H"><span class="term"><code class="option">-H</code>, </span><span class="term"><code class="option">--host=</code></span><a class="headerlink" title="Permalink to this term" href="#-H"></a></dt><dd><p><a name="host-text"></a>Execute the operation remotely. Specify a hostname, or a
91 username and hostname separated by "<code class="literal">@</code>", to
92 connect to. The hostname may optionally be suffixed by a
93 container name, separated by "<code class="literal">:</code>", which
94 connects directly to a specific container on the specified
95 host. This will use SSH to talk to the remote machine manager
96 instance. Container names may be enumerated with
97 <span class="command"><strong>machinectl -H
98 <em class="replaceable"><code>HOST</code></em></strong></span>.</p></dd><dt id="-M"><span class="term"><code class="option">-M</code>, </span><span class="term"><code class="option">--machine=</code></span><a class="headerlink" title="Permalink to this term" href="#-M"></a></dt><dd><p><a name="machine-text"></a>Execute operation on a local container. Specify a
99 container name to connect to.</p></dd><dt id="--on-active="><span class="term"><code class="option">--on-active=</code>, </span><span class="term"><code class="option">--on-boot=</code>, </span><span class="term"><code class="option">--on-startup=</code>, </span><span class="term"><code class="option">--on-unit-active=</code>, </span><span class="term"><code class="option">--on-unit-inactive=</code></span><a class="headerlink" title="Permalink to this term" href="#--on-active="></a></dt><dd><p>Defines monotonic timers relative to different
100 starting points. Also see <code class="varname">OnActiveSec=</code>,
101 <code class="varname">OnBootSec=</code>,
102 <code class="varname">OnStartupSec=</code>,
103 <code class="varname">OnUnitActiveSec=</code> and
104 <code class="varname">OnUnitInactiveSec=</code> in
105 <a href="systemd.timer.html"><span class="citerefentry"><span class="refentrytitle">systemd.timer</span>(5)</span></a>. This
106 options have no effect in conjunction with
107 <code class="option">--scope</code>.</p></dd><dt id="--on-calendar="><span class="term"><code class="option">--on-calendar=</code></span><a class="headerlink" title="Permalink to this term" href="#--on-calendar="></a></dt><dd><p>Defines realtime (i.e. wallclock) timers with
108 calendar event expressions. Also see
109 <code class="varname">OnCalendar=</code> in
110 <a href="systemd.timer.html"><span class="citerefentry"><span class="refentrytitle">systemd.timer</span>(5)</span></a>. This
111 option has no effect in conjunction with
112 <code class="option">--scope</code>.</p></dd><dt id="--timer-property="><span class="term"><code class="option">--timer-property=</code></span><a class="headerlink" title="Permalink to this term" href="#--timer-property="></a></dt><dd><p>Sets a timer unit property for the timer unit
113 that is created. It is similar with
114 <code class="option">--property</code> but only for created timer
115 unit. This option only has effect in conjunction with
116 <code class="option">--on-active=</code>, <code class="option">--on-boot=</code>,
117 <code class="option">--on-startup=</code>,
118 <code class="option">--on-unit-active=</code>,
119 <code class="option">--on-unit-inactive=</code>,
120 <code class="option">--on-calendar=</code>. This takes an assignment in
121 the same format as
122 <a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>'s
123 <span class="command"><strong>set-property</strong></span> command.</p></dd><dt id="-h"><span class="term"><code class="option">-h</code>, </span><span class="term"><code class="option">--help</code></span><a class="headerlink" title="Permalink to this term" href="#-h"></a></dt><dd><p><a name="help-text"></a>Print a short help text and exit.
124 </p></dd><dt id="--version"><span class="term"><code class="option">--version</code></span><a class="headerlink" title="Permalink to this term" href="#--version"></a></dt><dd><p><a name="version-text"></a>Print a short version string and exit.</p></dd></dl></div><p>All command line arguments after the first non-option
125 argument become part of the command line of the launched
126 process. If a command is run as service unit, its first argument
127 needs to be an absolute binary path.</p></div><div class="refsect1"><a name="idm140717670136336"></a><h2 id="Exit status">Exit status<a class="headerlink" title="Permalink to this headline" href="#Exit%20status"></a></h2><p>On success, 0 is returned, a non-zero failure
128 code otherwise.</p></div><div class="refsect1"><a name="idm140717670135184"></a><h2 id="Examples">Examples<a class="headerlink" title="Permalink to this headline" href="#Examples"></a></h2><p>The following command will log the environment variables
129 provided by systemd to services:</p><pre class="programlisting"># systemd-run env
130 Running as unit run-19945.service.
131 # journalctl -u run-19945.service
132 Sep 08 07:37:21 bupkis systemd[1]: Starting /usr/bin/env...
133 Sep 08 07:37:21 bupkis systemd[1]: Started /usr/bin/env.
134 Sep 08 07:37:21 bupkis env[19948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
135 Sep 08 07:37:21 bupkis env[19948]: LANG=en_US.UTF-8
136 Sep 08 07:37:21 bupkis env[19948]: BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.x86_64</pre><p>The following command invokes the
137 <a href="http://man7.org/linux/man-pages/man8/updatedb.8.html"><span class="citerefentry"><span class="refentrytitle">updatedb</span>(8)</span></a>
138 tool, but lowers the block IO weight for it to 10. See
139 <a href="systemd.resource-control.html"><span class="citerefentry"><span class="refentrytitle">systemd.resource-control</span>(5)</span></a>
140 for more information on the <code class="varname">BlockIOWeight=</code>
141 property.</p><pre class="programlisting"># systemd-run -p BlockIOWeight=10 updatedb</pre><p>The following command will touch a file after 30 seconds.</p><pre class="programlisting"># date; systemd-run --on-active=30 --timer-property=AccuracySec=100ms /bin/touch /tmp/foo
142 Mon Dec 8 20:44:24 KST 2014
143 Running as unit run-71.timer.
144 Will run as unit run-71.service.
145 # journalctl -b -u run-73.timer
146 -- Logs begin at Fri 2014-12-05 19:09:21 KST, end at Mon 2014-12-08 20:44:54 KST. --
147 Dec 08 20:44:38 container systemd[1]: Starting /bin/touch /tmp/foo.
148 Dec 08 20:44:38 container systemd[1]: Started /bin/touch /tmp/foo.
149 # journalctl -b -u run-73.service
150 -- Logs begin at Fri 2014-12-05 19:09:21 KST, end at Mon 2014-12-08 20:44:54 KST. --
151 Dec 08 20:44:48 container systemd[1]: Starting /bin/touch /tmp/foo...
152 Dec 08 20:44:48 container systemd[1]: Started /bin/touch /tmp/foo.</pre></div><div class="refsect1"><a name="idm140717670127968"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
153 <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
154 <a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>,
155 <a href="systemd.unit.html"><span class="citerefentry"><span class="refentrytitle">systemd.unit</span>(5)</span></a>,
156 <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
157 <a href="systemd.scope.html"><span class="citerefentry"><span class="refentrytitle">systemd.scope</span>(5)</span></a>,
158 <a href="systemd.slice.html"><span class="citerefentry"><span class="refentrytitle">systemd.slice</span>(5)</span></a>,
159 <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>,
160 <a href="systemd.resource-control.html"><span class="citerefentry"><span class="refentrytitle">systemd.resource-control</span>(5)</span></a>,
161 <a href="systemd.timer.html"><span class="citerefentry"><span class="refentrytitle">systemd.timer</span>(5)</span></a>,
162 <a href="machinectl.html"><span class="citerefentry"><span class="refentrytitle">machinectl</span>(1)</span></a>
163 </p></div></div></body></html>