From 679807de0c52b074bd3e0d62cfadf1c3a21dfc5c Mon Sep 17 00:00:00 2001 From: Robert Gustafsson Date: Fri, 6 Apr 2018 11:38:25 +0200 Subject: Add restart script --- script/restart.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 script/restart.sh (limited to 'script') diff --git a/script/restart.sh b/script/restart.sh new file mode 100644 index 0000000..39c17f4 --- /dev/null +++ b/script/restart.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +path=$1 +offset=$2 + +if ! [ -s $path ]; then + exit 1 +fi + +now=$(date +%s) +lastline=$(tail $path | grep "." | tail -1) +lastts=$(echo "$lastline" | grep -oP '^\d+') + +if [ -z $lastts ]; then + exit 1 +fi + +tswithoffset=$(($lastts + $offset)) +if [ $now -gt $tswithoffset ]; then + echo "Restart" +fi -- cgit v1.2.3