diff options
author | Robert Gustafsson <robg@student.chalmers.se> | 2018-04-06 11:38:25 +0200 |
---|---|---|
committer | Robert Gustafsson <robg@student.chalmers.se> | 2018-04-06 11:38:52 +0200 |
commit | 679807de0c52b074bd3e0d62cfadf1c3a21dfc5c (patch) | |
tree | f7a4965e0ea696dec65efe860d5381cc1449c73c /script | |
parent | 73e3757e5e314295a8cd9020022f2a1bad3f1ddc (diff) | |
download | midbro-679807de0c52b074bd3e0d62cfadf1c3a21dfc5c.tar.gz midbro-679807de0c52b074bd3e0d62cfadf1c3a21dfc5c.tar.bz2 |
Add restart script
Diffstat (limited to 'script')
-rw-r--r-- | script/restart.sh | 21 |
1 files changed, 21 insertions, 0 deletions
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 |