Systemd

systemd 啟動看門狗的問題

  • February 10, 2019

我正在嘗試啟用該watchdog服務(在 Raspbian Jessie 上)。

我已經安裝watchdog並(希望)配置了它。 sudo systemctl start watchdog似乎可以開始了

systemctl status watchdog.service顯示它正在執行:-

● watchdog.service - watchdog daemon
  Loaded: loaded (/lib/systemd/system/watchdog.service; static)
  Active: active (running) since Mon 2017-02-20 15:52:46 AEDT; 22s ago
 Process: 1828 ExecStart=/bin/sh -c [ $run_watchdog != 1 ] || exec /usr/sbin/watchdog $watchdog_options (code=exited, status=0/SUCCESS)
 Process: 1824 ExecStartPre=/bin/sh -c [ -z "${watchdog_module}" ] || [ "${watchdog_module}" = "none" ] || /sbin/modprobe $watchdog_module (code=exited, status=0/SUCCESS)
Main PID: 1831 (watchdog)
  CGroup: /system.slice/watchdog.service
          └─1831 /usr/sbin/watchdog

當我嘗試啟用它時,sudo systemctl enable watchdog我得到了這個奇怪的輸出

Synchronizing state for watchdog.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d watchdog defaults
Executing /usr/sbin/update-rc.d watchdog enable
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).

嘗試sudo update-rc.d watchdog enable似乎沒有成功 systemctl list-units | grep 看門狗

cat /lib/systemd/system/watchdog.service確實沒有

$$ Install $$部分

[Unit]
Description=watchdog daemon
Conflicts=wd_keepalive.service
After=multi-user.target
OnFailure=wd_keepalive.service

[Service]
Type=forking
EnvironmentFile=/etc/default/watchdog
ExecStartPre=/bin/sh -c '[ -z "${watchdog_module}" ] || [ "${watchdog_module}" = "none" ] || /sbin/modprobe $watchdog_module
ExecStart=/bin/sh -c '[ $run_watchdog != 1 ] || exec /usr/sbin/watchdog $watchdog_options'
ExecStopPost=/bin/sh -c '[ $run_wd_keepalive != 1 ] || false'

[Install]

我怎樣才能調試它,並讓看門狗在啟動時執行


我將以下內容添加到/lib/systemd/system/watchdog.service

[Install]
WantedBy=multi-user.target

watchdog現在開始。我需要測試以確保它有效!

這是一個已知的 Debian 錯誤。Debian 看門狗軟體包的 systemd 集成經歷了幾輪,變化很大。正如您所發現的,作為 Debian 8 發布的 watchdog 軟體包實際上是不起作用的。預發布測試沒有發現這一點。

該錯誤已針對該軟體包的 5.15-1 版本進行了修復,此外還有另一個修復錯誤的服務單元語法(在您的服務單元中也可見)。這個版本在 Debian 8 backports 中不可用,儘管已經提出了兩個請求(並且顯然被忽略了)。

進一步閱讀

引用自:https://unix.stackexchange.com/questions/346224