]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd-notify.xml
man: document that start limiting of GC'ed units doesn't work (#7337)
[thirdparty/systemd.git] / man / systemd-notify.xml
CommitLineData
c5abba08
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
c5abba08
LP
4
5<!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
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
c5abba08
LP
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
5430f7f2 18 Lesser General Public License for more details.
c5abba08 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
c5abba08
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
dfdebb1b 24<refentry id="systemd-notify"
798d3a52
ZJS
25 xmlns:xi="http://www.w3.org/2001/XInclude">
26
27 <refentryinfo>
28 <title>systemd-notify</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-notify</refentrytitle>
43 <manvolnum>1</manvolnum>
44 </refmeta>
45
46 <refnamediv>
47 <refname>systemd-notify</refname>
48 <refpurpose>Notify service manager about start-up completion and other daemon status changes</refpurpose>
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <cmdsynopsis>
53 <command>systemd-notify <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">VARIABLE=VALUE</arg></command>
54 </cmdsynopsis>
55 </refsynopsisdiv>
56
57 <refsect1>
58 <title>Description</title>
59
60 <para><command>systemd-notify</command> may be called by daemon
61 scripts to notify the init system about status changes. It can be
62 used to send arbitrary information, encoded in an
b938cb90 63 environment-block-like list of strings. Most importantly, it can be
798d3a52
ZJS
64 used for start-up completion notification.</para>
65
66 <para>This is mostly just a wrapper around
67 <function>sd_notify()</function> and makes this functionality
68 available to shell scripts. For details see
69 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
70 </para>
71
72 <para>The command line may carry a list of environment variables
73 to send as part of the status update.</para>
74
b3bb6476
LP
75 <para>Note that systemd will refuse reception of status updates from this command unless
76 <varname>NotifyAccess=</varname> is set for the service unit this command is called from.</para>
77
78 <para>Note that <function>sd_notify()</function> notifications may be attributed to units correctly only if either
79 the sending process is still around at the time PID 1 processes the message, or if the sending process is
80 explicitly runtime-tracked by the service manager. The latter is the case if the service manager originally forked
81 off the process, i.e. on all processes that match <varname>NotifyAccess=</varname><option>main</option> or
82 <varname>NotifyAccess=</varname><option>exec</option>. Conversely, if an auxiliary process of the unit sends an
83 <function>sd_notify()</function> message and immediately exits, the service manager might not be able to properly
84 attribute the message to the unit, and thus will ignore it, even if
85 <varname>NotifyAccess=</varname><option>all</option> is set for it.</para>
aa203945
LP
86
87 <para><command>systemd-notify</command> will first attempt to invoke <function>sd_notify()</function> pretending to
88 have the PID of the invoking process. This will only succeed when invoked with sufficient privileges. On failure,
89 it will then fall back to invoking it under its own PID. This behaviour is useful in order that when the tool is
90 invoked from a shell script the shell process — and not the <command>systemd-notify</command> process — appears as
91 sender of the message, which in turn is helpful if the shell process is the main process of a service, due to the
92 limitations of <varname>NotifyAccess=</varname><option>all</option> described above.</para>
798d3a52
ZJS
93 </refsect1>
94
95 <refsect1>
96 <title>Options</title>
97
98 <para>The following options are understood:</para>
99
100 <variablelist>
101 <varlistentry>
102 <term><option>--ready</option></term>
103
104 <listitem><para>Inform the init system about service start-up
105 completion. This is equivalent to <command>systemd-notify
106 READY=1</command>. For details about the semantics of this
107 option see
108 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
109 </varlistentry>
110
111 <varlistentry>
112 <term><option>--pid=</option></term>
113
114 <listitem><para>Inform the init system about the main PID of
115 the daemon. Takes a PID as argument. If the argument is
116 omitted, the PID of the process that invoked
117 <command>systemd-notify</command> is used. This is equivalent
118 to <command>systemd-notify MAINPID=$PID</command>. For details
119 about the semantics of this option see
120 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
121 </varlistentry>
122
123 <varlistentry>
124 <term><option>--status=</option></term>
125
126 <listitem><para>Send a free-form status string for the daemon
127 to the init systemd. This option takes the status string as
128 argument. This is equivalent to <command>systemd-notify
1eecafb8 129 STATUS=…</command>. For details about the semantics of this
798d3a52
ZJS
130 option see
131 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
132 </varlistentry>
133
134 <varlistentry>
135 <term><option>--booted</option></term>
136
137 <listitem><para>Returns 0 if the system was booted up with
138 systemd, non-zero otherwise. If this option is passed, no
139 message is sent. This option is hence unrelated to the other
140 options. For details about the semantics of this option, see
94f099d8 141 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>. An
a8eaaee7 142 alternate way to check for this state is to call
94f099d8
LP
143 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
144 with the <command>is-system-running</command> command. It will
145 return <literal>offline</literal> if the system was not booted
146 with systemd. </para></listitem>
798d3a52
ZJS
147 </varlistentry>
148
149 <xi:include href="standard-options.xml" xpointer="help" />
150 <xi:include href="standard-options.xml" xpointer="version" />
151 </variablelist>
152
153 </refsect1>
154
155 <refsect1>
156 <title>Exit status</title>
157
158 <para>On success, 0 is returned, a non-zero failure code
159 otherwise.</para>
160 </refsect1>
161
162 <refsect1>
163 <title>Example</title>
164
165 <example>
166 <title>Start-up Notification and Status Updates</title>
167
168 <para>A simple shell daemon that sends start-up notifications
169 after having set up its communication channel. During runtime it
170 sends further status updates to the init system:</para>
171
172 <programlisting>#!/bin/bash
c61fbdfc
LP
173
174mkfifo /tmp/waldo
1eecafb8 175systemd-notify --ready --status="Waiting for data…"
c61fbdfc
LP
176
177while : ; do
0521e286
LP
178 read a &lt; /tmp/waldo
179 systemd-notify --status="Processing $a"
c61fbdfc 180
1eecafb8 181 # Do something with $a …
c61fbdfc 182
1eecafb8 183 systemd-notify --status="Waiting for data…"
c61fbdfc 184done</programlisting>
798d3a52
ZJS
185 </example>
186 </refsect1>
187
188 <refsect1>
189 <title>See Also</title>
190 <para>
191 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
192 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
193 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
194 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
195 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>
196 </para>
197 </refsect1>
c5abba08
LP
198
199</refentry>