From 37db988e1aa49411e6000df64220aeebf8c4a198 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 27 Feb 2023 11:04:35 -0500 Subject: init --- refresh.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 refresh.sh (limited to 'refresh.sh') diff --git a/refresh.sh b/refresh.sh new file mode 100755 index 0000000..c48c834 --- /dev/null +++ b/refresh.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +CMD="$1" +FILE="$2" +#LOG="$(mktemp /tmp/${CMD}log.XXXXXX)" + +getChangeTime () { + stat -c '%Y' "$FILE" +} + +start () { + $CMD $FILE & #2>>$LOG + PSID=$! + CHANGETIME="$(getChangeTime)" + echo "Started $CMD $FILE at $(TZ=UTC date)" +} + +start + +while true; do + NEWCHANGETIME="$(getChangeTime)" + if [ $NEWCHANGETIME -ne $CHANGETIME ]; then + echo "File has changed!" + kill $PSID + start + fi; + sleep 1 +done; -- cgit v1.2.3