Skip to content

Instantly share code, notes, and snippets.

@cupracer
Last active August 26, 2020 14:20
Show Gist options
  • Save cupracer/087654281d2bdbf00f4bb7c91d2572ef to your computer and use it in GitHub Desktop.
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
#!/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