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