← back to Homesonspec
ops: minute-precision retention (find -mtime +N truncates to >=N+1 days) — TK-10236
5c1b5c47c6b4acfee6cb9009cde6ef48cfa982ae · 2026-08-05 07:50:32 -0700 · Steve Abrams
Files touched
M ops/prune-snapshot-cache.sh
Diff
commit 5c1b5c47c6b4acfee6cb9009cde6ef48cfa982ae
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Aug 5 07:50:32 2026 -0700
ops: minute-precision retention (find -mtime +N truncates to >=N+1 days) — TK-10236
---
ops/prune-snapshot-cache.sh | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/ops/prune-snapshot-cache.sh b/ops/prune-snapshot-cache.sh
index d3ce2b1a..f05a8cf9 100755
--- a/ops/prune-snapshot-cache.sh
+++ b/ops/prune-snapshot-cache.sh
@@ -18,6 +18,9 @@ SNAP="${SNAP_DIR:-/root/Projects/homesonspec/var/snapshots}"
RETAIN_DAYS="${RETAIN_DAYS:-7}"
LIVE_MIN="${LIVE_MIN:-15}"
APPLY=0; [ "${1:-}" = "--apply" ] && APPLY=1
+# Use minute precision, not -mtime: `find -mtime +N` integer-truncates age, so +7 == ">=8 days".
+# -mmin +(RETAIN_DAYS*1440) means ">RETAIN_DAYS.0 days" exactly, matching the reclaim curve.
+RETAIN_MIN=$((RETAIN_DAYS*1440))
gb(){ awk -v b="${1:-0}" 'BEGIN{printf "%.2f", b/1073741824}'; }
[ -d "$SNAP" ] || { echo "ERROR: snapshot dir not found: $SNAP"; exit 1; }
@@ -35,14 +38,14 @@ for d in "$SNAP"/*/; do
if [ -n "$(find "$d" -type f -mmin -"$LIVE_MIN" 2>/dev/null | head -1)" ]; then
skipped="$skipped $b"; continue
fi
- cnt=$(find "$d" -type f -mtime +"$RETAIN_DAYS" 2>/dev/null | wc -l | tr -d ' ')
+ cnt=$(find "$d" -type f -mmin +"$RETAIN_MIN" 2>/dev/null | wc -l | tr -d ' ')
[ "${cnt:-0}" -eq 0 ] && continue
- bytes=$(find "$d" -type f -mtime +"$RETAIN_DAYS" -printf '%s\n' 2>/dev/null | awk '{s+=$1} END{print s+0}')
+ bytes=$(find "$d" -type f -mmin +"$RETAIN_MIN" -printf '%s\n' 2>/dev/null | awk '{s+=$1} END{print s+0}')
printf "%-30s %10d %9sG %s\n" "$b" "$cnt" "$(gb "$bytes")" "$([ $APPLY -eq 1 ] && echo DELETE || echo would-prune)"
total_files=$((total_files+cnt)); total_bytes=$((total_bytes+bytes))
if [ $APPLY -eq 1 ]; then
- find "$d" -type f -mtime +"$RETAIN_DAYS" -printf '%p\n' 2>/dev/null >> "$MANIFEST"
- find "$d" -type f -mtime +"$RETAIN_DAYS" -delete 2>/dev/null
+ find "$d" -type f -mmin +"$RETAIN_MIN" -printf '%p\n' 2>/dev/null >> "$MANIFEST"
+ find "$d" -type f -mmin +"$RETAIN_MIN" -delete 2>/dev/null
fi
done
echo ""
← eb45f0f3 ops: age-based retention prune for snapshot page-cache (7d,
·
back to Homesonspec
·
prune: fail-open per-builder (|| true vs pipefail abort) + S 53ff5542 →