From 2a3c9f52dca393f2d2e29ced32e652c8b967162c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 4 Feb 2016 16:53:15 +0100 Subject: [PATCH] added logging to syslog --- restartcloudbot.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/restartcloudbot.sh b/restartcloudbot.sh index 8b28622..5903819 100755 --- a/restartcloudbot.sh +++ b/restartcloudbot.sh @@ -1,9 +1,21 @@ -#!/bin/sh - +#!/bin/bash cd $(dirname $0) -while /bin/true; + +PIDS="" +for i in $(ps -awx | grep -i [c]loudbot | sed "s/^\s*//" | cut -d" " -f1); do + if [ $i != $$ ]; then + PIDS="$i $PIDS" + fi +done +if [ ! -z "$PIDS" ]; then + kill $PIDS + sleep 10 + kill -9 $PIDS >/dev/null 2>&1 +fi + +while true do - sudo -u cloudbot ./cloudbot.py + sudo -u cloudbot ./cloudbot.py 2>&1 | logger -s -t $(basename $0) sleep 10 done