给树莓派安装看门狗的两种方法,二代B
树莓派的CPU是保护有硬件看门狗的,可以通过安装模块和值守程序来实现看门狗防止树莓派死机。
安装方法一:
watchdog.sh的源码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/usr/bin/env bash echo "[+] Activating Temperature Sensor" modprobe bcm2708_wdog echo "bcm2708_wdog" >> /etc/modules echo "[+]Installing Watchdog" apt-get -y install watchdog chkconfig echo "[+]Setting Up Watchdog" chkconfig watchdog on sed -i 's/#max-load-1[^5]/max-load-1\ /g' /etc/watchdog .conf sed -i 's/#\(watchdog-device\t[\ ]*\)\=/\1\t\=/g' /etc/watchdog .conf sed -i 's/#\(temperature-device[\ ]*\)\=/\1\ \= \/sys\/class\/thermal\/thermal\_zone0\/temp/g' /etc/watchdog .conf sed -i 's/#\(max-temperature[\ ]*\)\=\ 120/\1\ \=\ 75000/g' /etc/watchdog .conf sed -i 's/#\(interval[\ ]*\)\=\ 1/\1\ \=\ 10 /g' /etc/watchdog .conf /etc/init .d /watchdog start |
运行:
1
|
sudo sh watchdog.sh |
安装方法二:
1.加载看门狗模块,编辑/etc/modules文件,添加一行“bcm2708_wdog”
1
2
|
sudo modprobe bcm2708_wdog sudo nano /etc/modules |
添加一行”bcm2708_wdog”
2.安装系统配置软件和看门狗程序
1
|
sudo apt-get install chkconfig watchdog |
3.配置看门狗程序,编辑“/etc/watchdog.conf”文件
1
|
sudo nano /etc/watchdog .conf |
去掉 watchdog-device = /dev/watchdog 前的#号,让看门狗设备对应树莓派的硬件看门狗
去掉 max-load-1 = 24 前的#号,当1分钟load进程超过24个的时候就会重启
还可以设置高温复位:
去掉
temperature-device =
max-temperature = 120
前的#号,改为
temperature-device = /sys/class/thermal/thermal_zone0/temp
max-temperature = 80000
温度超过80度就会引起重启,保护CPU。
配置完后,保存(Ctrl+O),退出(ctrl+x)。
4.配置看门狗程序,开机自动运行
1
|
chkconfig watchdog on |
5.启动看门狗
1
|
sudo /etc/init .d /watchdog start |
【推荐】FlashTable:表单开发界的极速跑车,让你的开发效率一路狂飙
【推荐】Flutter适配HarmonyOS 5知识地图,实战解析+高频避坑指南
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一次 .NET 性能优化之旅:将 GC 压力降低 99%
· MySQL索引完全指南:让你的查询速度飞起来
· 一个字符串替换引发的性能血案:正则回溯与救赎之路
· 为什么说方法的参数最好不要超过4个?
· C#.Net 筑基-优雅 LINQ 的查询艺术
· 一次 .NET 性能优化之旅:将 GC 压力降低 99%
· 我用这13个工具,让开发效率提升了5倍!
· 32岁入行STM32迟吗?
· C#.Net筑基-泛型T & 协变逆变
· Coze工作流实战:一键生成鸡汤视频——厉害的人,早已戒掉情绪