Linux防止误关机
Linux防止误关机
- 安装reboot-guard
- 结果验证
- 关机
安装reboot-guard
兼容python2
和python3
https://github.com/stephanritscher/reboot-guard
# 下载
wget -cP /usr/sbin/ https://raw.githubusercontent.com/stephanritscher/reboot-guard/refs/heads/master/rguard# 赋予可执行权限
chmod +x /usr/sbin/rguard# 下载service文件
wget -cP /etc/systemd/system/ https://raw.githubusercontent.com/stephanritscher/reboot-guard/refs/heads/master/rguard.service# 重载服务
systemctl daemon-reload# 设置开机自启动
systemctl enable --now rguard.service
当关机保护被停止时
,手动启动关机保护
# 启动关机保护
rguard -1
结果验证
关机命令 | 重启命令 |
---|---|
poweroff | reboot |
init 0 | init 6 |
shutdown now | shutdown -r now |
halt |
systemctl关机命令 | systemctl重启命令 |
---|---|
systemctl poweroff | systemctl reboot |
关机
# 停止关机保护
rguard -0# 执行关机命令
poweroff