1SYSTEMD-NOTIFY(1) systemd-notify SYSTEMD-NOTIFY(1)
2
3
4
6 systemd-notify - Notify service manager about start-up completion and
7 other daemon status changes
8
10 systemd-notify [OPTIONS...] [VARIABLE=VALUE...]
11
13 systemd-notify may be called by daemon scripts to notify the init
14 system about status changes. It can be used to send arbitrary
15 information, encoded in an environment-block-like list of strings. Most
16 importantly, it can be used for start-up completion notification.
17
18 This is mostly just a wrapper around sd_notify() and makes this
19 functionality available to shell scripts. For details see sd_notify(3).
20
21 The command line may carry a list of environment variables to send as
22 part of the status update.
23
24 Note that systemd will refuse reception of status updates from this
25 command unless NotifyAccess= is set for the service unit this command
26 is called from.
27
28 Note that sd_notify() notifications may be attributed to units
29 correctly only if either the sending process is still around at the
30 time PID 1 processes the message, or if the sending process is
31 explicitly runtime-tracked by the service manager. The latter is the
32 case if the service manager originally forked off the process, i.e. on
33 all processes that match NotifyAccess=main or NotifyAccess=exec.
34 Conversely, if an auxiliary process of the unit sends an sd_notify()
35 message and immediately exits, the service manager might not be able to
36 properly attribute the message to the unit, and thus will ignore it,
37 even if NotifyAccess=all is set for it.
38
39 systemd-notify will first attempt to invoke sd_notify() pretending to
40 have the PID of the invoking process. This will only succeed when
41 invoked with sufficient privileges. On failure, it will then fall back
42 to invoking it under its own PID. This behaviour is useful in order
43 that when the tool is invoked from a shell script the shell process —
44 and not the systemd-notify process — appears as sender of the message,
45 which in turn is helpful if the shell process is the main process of a
46 service, due to the limitations of NotifyAccess=all described above.
47
49 The following options are understood:
50
51 --ready
52 Inform the init system about service start-up completion. This is
53 equivalent to systemd-notify READY=1. For details about the
54 semantics of this option see sd_notify(3).
55
56 --pid=
57 Inform the init system about the main PID of the daemon. Takes a
58 PID as argument. If the argument is omitted, the PID of the process
59 that invoked systemd-notify is used. This is equivalent to
60 systemd-notify MAINPID=$PID. For details about the semantics of
61 this option see sd_notify(3).
62
63 --uid=USER
64 Set the user ID to send the notification from. Takes a UNIX user
65 name or numeric UID. When specified the notification message will
66 be sent with the specified UID as sender, in place of the user the
67 command was invoked as. This option requires sufficient privileges
68 in order to be able manipulate the user identity of the process.
69
70 --status=
71 Send a free-form status string for the daemon to the init systemd.
72 This option takes the status string as argument. This is equivalent
73 to systemd-notify STATUS=.... For details about the semantics of
74 this option see sd_notify(3).
75
76 --booted
77 Returns 0 if the system was booted up with systemd, non-zero
78 otherwise. If this option is passed, no message is sent. This
79 option is hence unrelated to the other options. For details about
80 the semantics of this option, see sd_booted(3). An alternate way to
81 check for this state is to call systemctl(1) with the
82 is-system-running command. It will return "offline" if the system
83 was not booted with systemd.
84
85 -h, --help
86 Print a short help text and exit.
87
88 --version
89 Print a short version string and exit.
90
92 On success, 0 is returned, a non-zero failure code otherwise.
93
95 Example 1. Start-up Notification and Status Updates
96
97 A simple shell daemon that sends start-up notifications after having
98 set up its communication channel. During runtime it sends further
99 status updates to the init system:
100
101 #!/bin/bash
102
103 mkfifo /tmp/waldo
104 systemd-notify --ready --status="Waiting for data..."
105
106 while : ; do
107 read a < /tmp/waldo
108 systemd-notify --status="Processing $a"
109
110 # Do something with $a ...
111
112 systemd-notify --status="Waiting for data..."
113 done
114
116 systemd(1), systemctl(1), systemd.unit(5), sd_notify(3), sd_booted(3)
117
118
119
120systemd 245 SYSTEMD-NOTIFY(1)