Žyma: Watchdog

Raspberry Hardware Watchdog

Automatically power cycle the Raspberry Pi once it gets stuck.

1) Enable the hardware watchdog on your Pi and reboot

sudo su
echo 'dtparam=watchdog=on' >> /boot/config.txt

2) Install the watchdog system service

sudo apt-get update
sudo apt-get install watchdog

3) Configure the watchdog service

sudo su
echo 'watchdog-device = /dev/watchdog' >> /etc/watchdog.conf
echo 'watchdog-timeout = 15' >> /etc/watchdog.conf
echo 'max-load-1 = 24' >> /etc/watchdog.conf

4) Enable the service

sudo systemctl enable watchdog
sudo systemctl start watchdog
sudo systemctl status watchdog

Now next time your Raspberry Pi freezes, the hardware watchdog will restart it automatically after 15 seconds.

If you want to test this you can try running a fork bomb on your shell:

sudo bash -c ':(){ :|:& };:'

!!!Running this code will render your Raspberry Pi unaccessible until it’s reset by the watchdog.!!!