Linux "systemd-notify" Command Line Options and Examples
Notify service manager about start-up completion and other daemon status changes
systemd-notify may be called by daemon scripts to notify the init system about status changes. It can be used to send arbitrary information, encoded in an environment-block-like list of strings. Most importantly, it can be used for start-up completion notification.
systemd-notify [OPTIONS...] [VARIABLE=VALUE...]
Command Line Options:
Inform the init system about service start-up completion. This is equivalent to systemd-notify READY=1.For details about the semantics of this option see sd_notify(3).
systemd-notify --ready ...
Inform the init system about the main PID of the daemon. Takes a PID as argument. If the argument isomitted, the PID of the process that invoked systemd-notify is used. This is equivalent to systemd-notifyMAINPID=$PID. For details about the semantics of this option see sd_notify(3).
systemd-notify --pid ...
Set the user ID to send the notification from. Takes a UNIX user name or numeric UID. When specified thenotification message will be sent with the specified UID as sender, in place of the user the command wasinvoked as. This option requires sufficient privileges in order to be able manipulate the user identity ofthe process.
systemd-notify --uid ...
Send a free-form status string for the daemon to the init systemd. This option takes the status string asargument. This is equivalent to systemd-notify STATUS=.... For details about the semantics of this optionsee sd_notify(3).
systemd-notify --status ...
Returns 0 if the system was booted up with systemd, non-zero otherwise. If this option is passed, nomessage is sent. This option is hence unrelated to the other options. For details about the semantics ofthis option, see sd_booted(3). An alternate way to check for this state is to call systemctl(1) with theis-system-running command. It will return "offline" if the system was not booted with systemd.
systemd-notify --booted ...
Print a short help text and exit.
systemd-notify -h ...
Print a short version string and exit.EXIT STATUSOn success, 0 is returned, a non-zero failure code otherwise.EXAMPLEExample 1. Start-up Notification and Status UpdatesA simple shell daemon that sends start-up notifications after having set up its communication channel. Duringruntime it sends further status updates to the init system:#!/bin/bashmkfifo /tmp/waldosystemd-notify --ready --status="Waiting for data..."while : ; doread a < /tmp/waldosystemd-notify --status="Processing $a"# Do something with $a ...systemd-notify --status="Waiting for data..."done
systemd-notify --version ...