chiark / gitweb /
update TODO
[elogind.git] / man / systemd-notify.xml
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 2010 Lennart Poettering
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
24 <refentry id="systemd-notify"
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
61                 called by daemon scripts to notify the init system
62                 about status changes. It can be used to send arbitrary
63                 information, encoded in an environment-block-like list
64                 of strings. Most importantly it can be used for
65                 start-up completion notification.</para>
66
67                 <para>This is mostly just a wrapper around
68                 <function>sd_notify()</function> and makes this
69                 functionality available to shell scripts. For details
70                 see
71                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
72
73                 <para>The command line may carry a list of
74                 environment variables to send as part of the status
75                 update.</para>
76
77                 <para>Note that systemd will refuse reception of
78                 status updates from this command unless
79                 <varname>NotifyAccess=all</varname> is set for the
80                 service unit this command is called from.</para>
81
82         </refsect1>
83
84         <refsect1>
85                 <title>Options</title>
86
87                 <para>The following options are understood:</para>
88
89                 <variablelist>
90                         <varlistentry>
91                                 <term><option>--ready</option></term>
92
93                                 <listitem><para>Inform the init system
94                                 about service start-up
95                                 completion. This is equivalent to
96                                 <command>systemd-notify
97                                 READY=1</command>. For details about
98                                 the semantics of this option see
99                                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
100                         </varlistentry>
101
102                         <varlistentry>
103                                 <term><option>--pid=</option></term>
104
105                                 <listitem><para>Inform the init system
106                                 about the main PID of the
107                                 daemon. Takes a PID as argument. If
108                                 the argument is omitted, the PID of the
109                                 process that invoked
110                                 <command>systemd-notify</command> is
111                                 used. This is equivalent to
112                                 <command>systemd-notify
113                                 MAINPID=$PID</command>. For details
114                                 about the semantics of this option see
115                                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
116                         </varlistentry>
117
118                         <varlistentry>
119                                 <term><option>--status=</option></term>
120
121                                 <listitem><para>Send a free-form
122                                 status string for the daemon to the
123                                 init systemd. This option takes the
124                                 status string as argument. This is
125                                 equivalent to <command>systemd-notify
126                                 STATUS=...</command>. For details
127                                 about the semantics of this option see
128                                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
129                         </varlistentry>
130
131                         <varlistentry>
132                                 <term><option>--booted</option></term>
133
134                                 <listitem><para>Returns 0 if the
135                                 system was booted up with systemd,
136                                 non-zero otherwise. If this option is
137                                 passed, no message is sent. This option
138                                 is hence unrelated to the other
139                                 options. For details about the
140                                 semantics of this option, see
141                                 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
142                         </varlistentry>
143
144                         <xi:include href="standard-options.xml" xpointer="help" />
145                         <xi:include href="standard-options.xml" xpointer="version" />
146                 </variablelist>
147
148         </refsect1>
149
150         <refsect1>
151                 <title>Exit status</title>
152
153                 <para>On success, 0 is returned, a non-zero failure
154                 code otherwise.</para>
155         </refsect1>
156
157         <refsect1>
158                 <title>Example</title>
159
160                 <example>
161                         <title>Start-up Notification and Status Updates</title>
162
163                         <para>A simple shell daemon that sends
164                         start-up notifications after having set up its
165                         communication channel. During runtime it sends
166                         further status updates to the init
167                         system:</para>
168
169                         <programlisting>#!/bin/bash
170
171 mkfifo /tmp/waldo
172 systemd-notify --ready --status="Waiting for data..."
173
174 while : ; do
175         read a &lt; /tmp/waldo
176         systemd-notify --status="Processing $a"
177
178         # Do something with $a ...
179
180         systemd-notify --status="Waiting for data..."
181 done</programlisting>
182                 </example>
183         </refsect1>
184
185         <refsect1>
186                 <title>See Also</title>
187                 <para>
188                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
189                         <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
190                         <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
191                         <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
192                         <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>
193                 </para>
194         </refsect1>
195
196 </refentry>