SYSTEMD-NOTIFY(1) | systemd-notify | SYSTEMD-NOTIFY(1) |
systemd-notify - 向 systemd 報告服務狀態的變化
systemd-notify [OPTIONS...] [VARIABLE=VALUE...]
systemd-notify 可用於 在守護進程腳本中向 systemd 報告進程狀態的變化。 可用於發送任意信息, 其中最重要的是 報告"啓動已完成"的消息。
此工具基本上就是對 sd_notify() 的簡單包裝, 以便於在腳本中使用。詳見 sd_notify(3) 手冊。
注意,在報告狀態更新的同時, 還可以傳遞一系列環境變量。
注意, 除非在調用此命令的服務單元中設置了 NotifyAccess=all , 否則 systemd 將會拒絕接受狀態更新的消息。
能夠識別的命令行選項如下:
--ready
--pid=
--status=
--booted
-h, --help
--version
返回值爲 0 表示成功, 非零返回值表示失敗代碼。
Example 1. 啓動通知與狀態更新
一個簡單的守護進程腳本,在創建好通信管道之後, 向 systemd 報告"啓動已完成"的消息。在運行時, 向 systemd 報告更多的狀態消息:
#!/bin/bash mkfifo /tmp/waldo systemd-notify --ready --status="Waiting for data..." while : ; do
read a < /tmp/waldo
systemd-notify --status="Processing $a"
# Do something with $a ...
systemd-notify --status="Waiting for data..." done
systemd(1), systemctl(1), systemd.unit(5), sd_notify(3), sd_booted(3)
本頁面中文版由中文 man 手冊頁計劃提供。
翻譯人員:金步國
金步國作品集:http://www.jinbuguo.com
中文 man
手冊頁計劃:https://github.com/man-pages-zh/manpages-zh
systemd 231 |