chiark / gitweb /
swap: add only swaps listed in /etc/fstab automatically to swap.target, others should...
[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 General Public License as published by
12   the Free Software Foundation; either version 2 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   General Public License for more details.
19
20   You should have received a copy of the GNU General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="systemd-notify">
25
26         <refentryinfo>
27                 <title>systemd-notify</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>systemd-notify</refentrytitle>
42                 <manvolnum>1</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>systemd-notify</refname>
47                 <refpurpose>Notify init system about start-up completion and other daemon status changes</refpurpose>
48         </refnamediv>
49
50         <refsynopsisdiv>
51                 <cmdsynopsis>
52                         <command>systemd-notify <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">VARIABLE=VALUE</arg></command>
53                 </cmdsynopsis>
54         </refsynopsisdiv>
55
56         <refsect1>
57                 <title>Description</title>
58
59                 <para><command>systemd-notify</command> may be
60                 called by daemon scripts to notify the init system
61                 about status changes. It can be used to send arbitrary
62                 information, encoded in an environment-block-like list
63                 of strings. Most importantly it can be used for
64                 start-up completion notification.</para>
65
66                 <para>This is mostly just a wrapper around
67                 <function>sd_notify()</function> and makes this
68                 functionality available to shell scripts. For details
69                 see
70                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
71
72                 <para>The command line may carry a list of
73                 environment variables to send as part of the status
74                 update.</para>
75
76                 <para>Note that systemd will refuse reception of
77                 status updates from this command unless
78                 <varname>NotifyAccess=all</varname> is set for the
79                 service unit this command is called from.</para>
80
81         </refsect1>
82
83         <refsect1>
84                 <title>Options</title>
85
86                 <para>The following options are understood:</para>
87
88                 <variablelist>
89                         <varlistentry>
90                                 <term><option>--h</option></term>
91                                 <term><option>--help</option></term>
92
93                                 <listitem><para>Prints a short help
94                                 text and exits.</para></listitem>
95                         </varlistentry>
96
97                         <varlistentry>
98                                 <term><option>--ready</option></term>
99
100                                 <listitem><para>Inform the init system
101                                 about service start-up
102                                 completion. This is equivalent to
103                                 <command>systemd-notify
104                                 READY=1</command>. For details about
105                                 the semantics of this option see
106                                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
107                         </varlistentry>
108
109                         <varlistentry>
110                                 <term><option>--pid=</option></term>
111
112                                 <listitem><para>Inform the init system
113                                 about the main PID of the
114                                 daemon. Takes a PID as argument. If
115                                 the argument is omitted the PID of the
116                                 process that invoked
117                                 <command>systemd-notify</command> is
118                                 used. This is equivalent to
119                                 <command>systemd-notify
120                                 MAINPID=$PID</command>. For details
121                                 about the semantics of this option see
122                                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
123                         </varlistentry>
124
125                         <varlistentry>
126                                 <term><option>--status=</option></term>
127
128                                 <listitem><para>Send a free-form
129                                 status string for the daemon to the
130                                 init systemd. This option takes the
131                                 status string as argument. This is
132                                 equivalent to <command>systemd-notify
133                                 STATUS=...</command>. For details
134                                 about the semantics of this option see
135                                 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
136                         </varlistentry>
137
138                         <varlistentry>
139                                 <term><option>--booted</option></term>
140
141                                 <listitem><para>Returns 0 if the
142                                 system was booted up with systemd,
143                                 non-zero otherwise. If this option is
144                                 passed no message is sent. This option
145                                 is hence unrelated to the other
146                                 options. For details about the
147                                 semantics of this option see
148                                 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
149                         </varlistentry>
150
151                         <varlistentry>
152                                 <term><option>--readahead=</option></term>
153
154                                 <listitem><para>Controls disk
155                                 read-ahead operations. The argument
156                                 must be a string, and either "cancel",
157                                 "done" or "noreplay". For details
158                                 about the semantics of this option see
159                                 <citerefentry><refentrytitle>sd_readahead</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
160                         </varlistentry>
161                 </variablelist>
162
163         </refsect1>
164
165         <refsect1>
166                 <title>Exit status</title>
167
168                 <para>On success 0 is returned, a non-zero failure
169                 code otherwise.</para>
170         </refsect1>
171
172         <refsect1>
173                 <title>Example</title>
174
175                 <example>
176                         <title>Start-up Notification and Status Updates</title>
177
178                         <para>A simple shell daemon that sends
179                         start-up notifications after having set up its
180                         communication channel. During runtime it sends
181                         further status updates to the init
182                         system:</para>
183
184                         <programlisting>#!/bin/bash
185
186 mkfifo /tmp/waldo
187 systemd-notify --ready --status="Waiting for data..."
188
189 while : ; do
190         read a &lt; /tmp/waldo
191         systemd-notify --status="Processing $a"
192
193         # Do something with $a ...
194
195         systemd-notify --status="Waiting for data..."
196 done</programlisting>
197                 </example>
198         </refsect1>
199
200         <refsect1>
201                 <title>See Also</title>
202                 <para>
203                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
204                         <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
205                         <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
206                         <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
207                         <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>
208                 </para>
209         </refsect1>
210
211 </refentry>