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