X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Fshutdown-detect-boot;fp=bin%2Fshutdown-detect-boot;h=7990229b7a10c28920a09e455fa7e1bbcccad5ee;hp=0000000000000000000000000000000000000000;hb=4beba551a913cd5a606759a7657db01a7c1cdfcb;hpb=575adc09ee2f6fc3223b8d43f545180cee736801 diff --git a/bin/shutdown-detect-boot b/bin/shutdown-detect-boot new file mode 100755 index 0000000..7990229 --- /dev/null +++ b/bin/shutdown-detect-boot @@ -0,0 +1,11 @@ +#! /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