On any modern Linux operating system that uses systemd you can configure systemd to interact with the hardware watchdog on your behalf, rather than doing it with watchdog service (apt install watchdog) or using a separate user-space daemon.
To enable the builtin systemd hardware watchdog, edit the following file:
sudo nano /etc/systemd/system.conf
uncomment and set the following values
RuntimeWatchdogSec=10 RebootWatchdogSec=2min WatchdogDevice=/dev/watchdog0
The first entry RuntimeWatchdogSec enables the systemd watchdog, RebootWatchdogSec sets the wait time after boot to start feeding the watchdog and WatchdogDevice is the hardware device to be fed.
Most modern hardware has a watchdog timer including Rapsberry Pis and most Intel chips beyond generation 7.
A bit more on the built-in systemd watchdog..
Systemd’s watchdog can be mainly used for 3 different actions:
- hardware reset (leveraging the CPU hardware watchdog exposed at /dev/watchdog). This is enabled by the
RuntimeWatchdogSec=
option in/etc/systemd/system.conf
- application reset, as long as this is foreseen in the systemd unit definition (see below service example)
- system reset as a fallback measure in response to multiple unsuccessful application resets. Also defined in the systemd unit
example unit file:
[Unit]
Description=My Little Daemon
Documentation=man:mylittled(8)
[Service]
ExecStart=/usr/bin/mylittled
WatchdogSec=30s
Restart=on-failure
StartLimitInterval=5min
StartLimitBurst=4
StartLimitAction=reboot-force
The example is taken from: http://0pointer.de/blog/projects/watchdog.html, which gives a pretty complete overview of what and how you can use the watchdog service.