From 3d112b32afd8bb785f6c6301293f80501649c7af Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Thu, 10 Dec 2020 12:29:26 +1100 Subject: [PATCH] syntax fix and indentation --- sss.sh | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/sss.sh b/sss.sh index fbda5db..0207686 100755 --- a/sss.sh +++ b/sss.sh @@ -37,32 +37,32 @@ function marksnap() { chcp cp $DEV ${MARKYEAR[2]} fi MARK=( "$1" "$2" $3 ) -fi +} { flock 9 -date "+$DEV: %Y-%m-%d %H:%M:%S ---- checking" >&2 -lscp -s $DEV | while read CNO DATE TIME REST ; do - TS="$DATE $TIME" - [ "$CNO" = "CNO" ] && continue - if [[ "$TS" > "$YEARLY" ]] ; then - marksnap YEAR "${DATE:0:4}" $CNO - elif [[ "$TS" > "$MONTHLY" ]] - marksnap MONTH "${DATE:5:2}" $CNO - elif [[ "$TS" > "$WEEKLY" ]] - # For older than most recent week, keep last snapshot each week - marksnap WEEK "$(( 7${DATE:8:2} / 7 - 100 ))" $CNO - elif [[ "$TS" > "$DAILY" ]] - marksnap DAY "${DATE:8:2}" $CNO - elif [[ "$TS" > "$HOURLY" ]] - marksnap HOUR "${DATE:8:2}-${TIME:0:2}" $CNO - else - echo "$CNO $DATE $TIME within last hour" - fi -done | if read X ; then - : # snapshot within last hour -else - date "+$DEV: new snapshot at %Y-%m-%d %H:%M:%S" >&2 - mkcp -s $DEV -fi + date "+$DEV: %Y-%m-%d %H:%M:%S ---- checking" >&2 + lscp -s $DEV | while read CNO DATE TIME REST ; do + TS="$DATE $TIME" + [ "$CNO" = "CNO" ] && continue + if [[ "$TS" > "$YEARLY" ]] ; then + marksnap YEAR "${DATE:0:4}" $CNO + elif [[ "$TS" > "$MONTHLY" ]] + marksnap MONTH "${DATE:5:2}" $CNO + elif [[ "$TS" > "$WEEKLY" ]] + # For older than most recent week, keep last snapshot each week + marksnap WEEK "$(( 7${DATE:8:2} / 7 - 100 ))" $CNO + elif [[ "$TS" > "$DAILY" ]] + marksnap DAY "${DATE:8:2}" $CNO + elif [[ "$TS" > "$HOURLY" ]] + marksnap HOUR "${DATE:8:2}-${TIME:0:2}" $CNO + else + echo "$CNO $DATE $TIME within last hour" + fi + done | if read X ; then + : # snapshot within last hour + else + date "+$DEV: new snapshot at %Y-%m-%d %H:%M:%S" >&2 + mkcp -s $DEV + fi } 9> /var/run/lock/sss.lock -- 2.39.2