Automatischer Reset (Watchdog)

piet66
Posts: 32
Joined: 04 Feb 2017 17:00

Re: Automatischer Reset (Watchdog)

Post by piet66 » 21 May 2018 12:05

Marsx79 wrote:
09 May 2018 11:51
Hallo Piet66

Kannst du den Script für den Cron Job zur Verfügung stellen?

Danke.
Hallo Marsx79,
habe deinen Post leider gerade erst bemerkt. Muss mir irgendwie entgangen sein.
Falls noch Interesse besteht, hier der Cron Job. Weil ich schon lange keine Abstürze mehr hatte, benutze ich den Job selbst nicht mehr.

Code: Select all

#!/bin/bash
#h-------------------------------------------------------------------------------
#h
#h Name:         z-way_watchdog.bash
#h Type:         Linux shell script
#h Purpose:      watchdog for z-way-server
#h Project:      z-Way Homeserver
#h Usage:        - put script to /home/pi/
#h               - make it executable
#h               - entry for cron (run every 10 minutes):
#h                   sudo crontab -e 
#h                   */10 * * * *   /home/pi/z-way_watchdog.bash
#h Result:       
#h Examples:     
#h Outline:      if state of z-way-server = "active (exited)" 
#h                      stops and restarts z-way-server
#h Resources:    z-way
#h Platforms:    Linux with systemd
#h Authors:      peb
#h Version:      V2.0 2017-09-22/peb
#v History:      V1.0 2017-07-18/peb first version
#h
#h-------------------------------------------------------------------------------

#-----------
#b Constants
#-----------
VERSION='V2.0'
WRITTEN='2017-09-22/peb'
SERVICE=z-way-server.service
YES=0
NO=1
LOG=`readlink -f $0`.log

#-----------
#b Variables
#-----------

#-----------
#b Functions
#-----------
function service_exited
{
      systemctl status $SERVICE | grep "active (exited)" > /dev/null
      # 1 = not found
      # 0 = found
      echo $?
}
function restart_service
{
      echo restarting service $SERVICE... >> $LOG
      systemctl stop $SERVICE
      sleep 10
      systemctl start $SERVICE
}
function restart_if_exited
{
      [ $(service_exited) == $YES ] && restart_service
}

#---------
#b Welcome
#---------
echo $0 $*
echo check_storage.bash $VERSION $WRITTEN

#------
#b Main
#------
cd `dirname $0`
restart_if_exited
-
Raspberry Pi 3 Model B Rev 1.2
Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux
Raspbian GNU/Linux 8
Z-Way version v2.3.7 from 2018-03-23 09:28:53 +0300 (build b1902d4433d1337bd488834db3347fa7ef8f8a33)

Post Reply