Luckily for us, the Broadcom BCM2835 SoC on the Raspberry Pi comes with a hardware-based watchdog timer that can do just that. You will find this specially useful if you have a Raspberry Pi in a remote location and the operating system hangs and there's no one around to reboot it.
Load the bcm2708_wdog kernel module
To load the watchdog kernel module right now, issue the following command:
$ sudo modprobe bcm2708_wdogIf you are running Raspbian, to load the module the next time the system boots, add a line to your /etc/modules file with "bcm2708_wdog". The -a option makes sure tee appends instead.
$ echo "bcm2708_wdog" | sudo tee -a /etc/modules
If you are running Arch Linux, add a file called "bcm2708_wdog.conf" with the text "bcm2708_wdog" in /etc/modules-load.d/ with the following command:
$ echo "bcm2708_wdog" | sudo tee /etc/modules-load.d/bcm2708_wdog.conf
Install the software watchdog daemon
In Raspbian, run the following command:
$ sudo apt-get install watchdog
But in Arch we use pacman:
$ sudo pacman -S watchdog
Then, make sure it runs after every boot.
In Raspbian, run:
$ sudo update-rc.d watchdog defaults
OR
$ sudo chkconfig --add watchdog
In Arch run the following:$ sudo systemctl enable watchdog
Configure the watchdog daemon
Open /etc/watchdog.conf with your favorite editor (mine is nano).
$ sudo nano /etc/watchdog.conf
Uncomment the line that starts with #watchdog-device by removing the hash (#) to enable the watchdog daemon to use the watchdog device.
Uncomment the line that says #max-load-1 = 24 by removing the hash symbol to reboot the device if the load goes over 24 over 1 minute. A load of 25 of one minute means that you would have needed 25 Raspberry Pis to complete that task in 1 minute. You may tweak this value to your liking.
Start the watchdog daemon
In Raspbian:$ sudo chkconfig watchdog on
or
$ sudo /etc/init.d/watchdog start
In Arch:
$ sudo systemctl start watchdog.service
That's it!
You are done! You may play around with the settings in /etc/watchdog.conf if you'd like.The watchdog daemon performs other tests that you will probably want to configure.
Arch Linux users: I'm well aware that the watchdog daemon is not necessary in Arch because you can enable watchdog features with systemd by editing /etc/systemd/system.conf but I prefer the watchdog daemon as it is much more featured.
Updates:
2013-01-17 11:45 AM EST: Fixed the chkconfig command to start and enable the watchdog daemon at startup.
Source: Raspberry Pi @ Gadgetoid
It's important to mention that the hardware watchdog timeout is 16 seconds, so you must set your heartbeat interval to something less than that. This is assuming that this post is correct.
ReplyDeleteWonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it. https://dieseltester-cn.com/diesel-injection-test-equipment-fuel-pump-tester-12psb-c/
ReplyDeleteHello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. auto repair near me
ReplyDeleteI needed to thank you for this phenomenal read!! I unquestionably adored each and every piece of it. I have you bookmarked your site to look at the new stuff you post. auto hail repair denver
ReplyDeleteWhen you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. auto reply text
ReplyDeleteThis is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works. purchase travel insurance - third party car insurance
ReplyDeleteRafting in Vjosa river in Albania is a wonderful experience. Vjosa is the most wild river of Europe so is definitely something worth trying. Travel Albania
ReplyDeletePTCL is Pakistan's 1st Telecommunication company. People usually face problem in Changing PTCL Wifi Password which is not an issue it can simply be changed by signing in to your PTCL account. PTCL has also launched Latest Packages
ReplyDelete