File: systemd-run.html

package info (click to toggle)
systemd 215-17
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 49,568 kB
  • sloc: ansic: 192,789; xml: 39,586; sh: 13,002; makefile: 4,700; perl: 1,461; python: 1,355
file content (116 lines) | stat: -rw-r--r-- 13,607 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<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>
    a.headerlink {
      color: #c60f0f;
      font-size: 0.8em;
      padding: 0 4px 0 4px;
      text-decoration: none;
      visibility: hidden;
    }

    a.headerlink:hover {
      background-color: #c60f0f;
      color: white;
    }

    h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
      visibility: visible;
    }
  </style><a href="index.html">Index </a>·
  <a href="systemd.directives.html">Directives </a>·
  <a href="../python-systemd/index.html">Python </a>·
  <a href="../libudev/index.html">libudev </a>·
  <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 215</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 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>
       [ARGS...]
       </p></div></div><div class="refsect1"><a name="idm214192991536"></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 start
    a transient <code class="filename">.service</code> or a
    <code class="filename">.scope</code> unit and run the specified
    <em class="replaceable"><code>COMMAND</code></em> in it.</p><p>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 show up in the output of <span class="command"><strong>systemctl
    list-units</strong></span> like any other unit. It will run in a clean
    and detached execution environment. <span class="command"><strong>systemd-run</strong></span>
    will start the service asynchronously in the background and
    immediately return.</p><p>If a command is run as transient scope unit, it will be
    started directly by <span class="command"><strong>systemd-run</strong></span> and thus
    inherit the execution environment of the caller. It is however
    managed by the service manager similar to normal services, and
    will also show up in the output of <span class="command"><strong>systemctl
    list-units</strong></span>. Execution in this case is synchronous, and
    execution will return only when the command finishes.</p></div><div class="refsect1"><a name="idm214193032512"></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
          the default transient <code class="filename">.service</code> unit.
          </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
        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
        unit that is created. This takes an assignment in the same
        format as
        <a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>'s
        <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
        unit. If not specified, the command itself will be used as a
        description. See <code class="varname">Description=</code> in
        <a href="systemd.unit.html"><span class="citerefentry"><span class="refentrytitle">systemd.unit</span>(5)</span></a>.
        </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
        <code class="filename">.scope</code> unit part of the specified slice,
        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
        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
        <code class="varname">RemainAfterExit=</code> in
        <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>.
        </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,
        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
        <code class="varname">SendSIGHUP=</code> in
        <a href="systemd.kill.html"><span class="citerefentry"><span class="refentrytitle">systemd.kill</span>(5)</span></a>.
        </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
        <code class="varname">Type=</code> in
        <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>. This
        option has no effect in conjunction with
        <code class="option">--scope</code>. Defaults to
        <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
        and group. Also see <code class="varname">User=</code> and
        <code class="varname">Group=</code> in
        <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
        nice level. Also see <code class="varname">Nice=</code> in
        <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
        environment variables set. Also see
        <code class="varname">Environment=</code> in
        <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,
      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
      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
      username and hostname separated by "<code class="literal">@</code>", to
      connect to. The hostname may optionally be suffixed by a
      container name, separated by "<code class="literal">:</code>", 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
      <span class="command"><strong>machinectl -H
      <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
      container name to connect to.</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.
    </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
    argument become part of the commandline of the launched
    process. If a command is run as service unit, its first argument
    needs to be an absolute binary path.</p></div><div class="refsect1"><a name="idm214193069376"></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
    code otherwise.</p></div><div class="refsect1"><a name="idm214193068192"></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
    provided by systemd to services:</p><pre class="programlisting"># systemd-run env
Running as unit run-19945.service.
# journalctl -u run-19945.service
Sep 08 07:37:21 bupkis systemd[1]: Starting /usr/bin/env...
Sep 08 07:37:21 bupkis systemd[1]: Started /usr/bin/env.
Sep 08 07:37:21 bupkis env[19948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Sep 08 07:37:21 bupkis env[19948]: LANG=en_US.UTF-8
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
    <a href="updatedb.html"><span class="citerefentry"><span class="refentrytitle">updatedb</span>(8)</span></a>
    tool, but lowers the block IO weight for it to 10. See
    <a href="systemd.resource-control.html"><span class="citerefentry"><span class="refentrytitle">systemd.resource-control</span>(5)</span></a>
    for more information on the <code class="varname">BlockIOWeight=</code>
    property.</p><pre class="programlisting"># systemd-run -p BlockIOWeight=10 updatedb</pre></div><div class="refsect1"><a name="idm214188097824"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
      <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
      <a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>,
      <a href="systemd.unit.html"><span class="citerefentry"><span class="refentrytitle">systemd.unit</span>(5)</span></a>,
      <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>,
      <a href="systemd.scope.html"><span class="citerefentry"><span class="refentrytitle">systemd.scope</span>(5)</span></a>,
      <a href="systemd.slice.html"><span class="citerefentry"><span class="refentrytitle">systemd.slice</span>(5)</span></a>,
      <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>,
      <a href="systemd.resource-control.html"><span class="citerefentry"><span class="refentrytitle">systemd.resource-control</span>(5)</span></a>,
      <a href="machinectl.html"><span class="citerefentry"><span class="refentrytitle">machinectl</span>(1)</span></a>
    </p></div></div></body></html>