--- /dev/null
+#! /bin/bash
+boot="boot $* boot=$(uptime -s) $(uptime -p)"
+echo "$(date --iso=seconds) uninit-time $boot" >>/var/log/shutdown-detect.log
+# Raspberry Pi 3B+: 15 sec
+sleep 60
+echo "$(date --iso=seconds) init-time $boot" >>/var/log/shutdown-detect.log
+if [ -e /var/log/shutdown-detect.ok ];then
+ rm -f /var/log/shutdown-detect.ok
+ exit 0
+fi
+echo "$(date --iso=seconds) unclean shutdown"|tee -a /var/log/shutdown-detect.log|mail -s "unclean shutdown: $(hostname)" jan@jankratochvil.net