How to use hardware watchdog in Ubuntu Core


Hardware watchdog is supported after snapd 2.34 or Core Image r5145.

A user can use the “snap set” command to config the watchdog parameters.

$ snap set core watchdog.runtime-timeout=1m
Set a timeout value in seconds (or in other time units if suffixed with “ms”, “min”, “h”, “d”, “w”). The watchdog hardware (/dev/watchdog) or the kernel option systemd.watchdog-device=) will be programmed to automatically reboot the system if it is not contacted within the specified timeout interval.

$ snap set core watchdog.shutdown-timeout=10m
It works as a safety net to ensure that the reboot takes place even if a clean reboot attempt times out. Note that the shutdown-timeout applies only to the second phase of the reboot, i.e. after all regular services are already terminated, and after the system and service manager process (PID 1) got replaced by the systemd-shutdown binary.

The function is implemented with systemd. The configuration can be validated in /etc/systemd/system.conf.d/10-snapd-watchdog.conf

How to use hardware WatchdogTimer

Dear chihchun:
The case you said is that snapd use the watchdog (indeed it’s support by systemd).
If a snap app want to use the hardware watchdog, what should we do ?

Best Regards


Currently, there is a limitation on access to hardware watchdog from snap app. There is no security interface for /dev/watchdog yet.

Could you share a bit more the use case, why do you like to manage hw watchdog from an application? That will help the core team to justify the feature request.


The update to watchdog timers with snap set do not reflect in the systemctl. Is this normal ?

$ systemctl show | grep -i watchdog
admin@FT8TB02:~$ sudo snap get core watchdog
Key                       Value
watchdog.runtime-timeout  2m


below command will show your current status of time out what you expect.

cat /etc/systemd/system.conf.d/10-snapd-watchdog.conf