aboutsummaryrefslogtreecommitdiff
path: root/script/restart.sh
blob: 39c17f4ecfd7768ab052cd435206d875f58597ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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