jeelink2mqtt_wdog.sh 858 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. # monitor "jeelink2mqtt.py"
  3. logfile="/home/pi/jeelink2mqtt_wdog.log"
  4. statfile=/tmp/jeelink2mqtt_running
  5. timestmp=`date "+%Y-%m-%d %H:%M:%S"`
  6. echo $timestmp starting wdog...>> $logfile
  7. while :
  8. do
  9. if [ -f "$statfile" ]
  10. then
  11. if test `find "$statfile" -mmin +2` # Statusfile darf maximal 2 Minuten alt sein, sonst hängt vermutlich etwas (WS liefert mindestens alle 60s was)
  12. then
  13. timestmp=`date "+%Y-%m-%d %H:%M:%S"`
  14. echo $timestmp statusfile too old - jeelink2mqtt..py seems to hang - restarting >> $logfile
  15. #killall wettersensoren.py
  16. systemctl restart jeelink2mqtt.service
  17. fi
  18. else
  19. timestmp=`date "+%Y-%m-%d %H:%M:%S"`
  20. echo $timestmp statusfile does not exist - jeelink2mqtt.py seems not to be running - restarting >> $logfile
  21. #killall wettersensoren.py
  22. systemctl restart jeelink2mqtt.service
  23. fi
  24. sleep 60
  25. done