Last active
August 26, 2020 14:20
-
-
Save cupracer/087654281d2bdbf00f4bb7c91d2572ef to your computer and use it in GitHub Desktop.
setup a watchdog which triggers a kernel panic if the script gets stuck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
KERNEL_MODULE=softdog | |
WATCHDOG_DEVICE=/dev/watchdog | |
LOGFILE=/deadmancheck.log | |
WATCHDOG_TIMEOUT=30 | |
SLEEPTIMER=3 | |
#### | |
lsmod | grep ${KERNEL_MODULE} || modprobe ${KERNEL_MODULE} soft_panic=1 soft_margin=${WATCHDOG_TIMEOUT} | |
while true; | |
do | |
touch ${WATCHDOG_DEVICE} | |
date | tee ${LOGFILE} | |
sleep ${SLEEPTIMER} | |
done | |
# INFO: disable watchdog by running: | |
# echo V > ${WATCHDOG_DEVICE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment