aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-27 09:16:18 -0500
committerCraig Jennings <c@cjennings.net>2026-04-27 09:16:18 -0500
commit369ae1d713ad3ed7a2b00c63b81cbb2a07fc0df3 (patch)
treeef3d940c85c3a8404e9be14f833ac2ddb139b902
parent4cd5089180d53ef3b980ad7506bfdd3fda32e9fc (diff)
downloadarchsetup-369ae1d713ad3ed7a2b00c63b81cbb2a07fc0df3.tar.gz
archsetup-369ae1d713ad3ed7a2b00c63b81cbb2a07fc0df3.zip
fix(log-cleanup): handle filenames without YYYY-MM-DD via epoch fallback
If no YYYY-MM-DD matches, the script now looks for a 10-digit epoch between underscores in the filename and converts it via date -d. The existing 24-hour mtime guard still protects the active session log from being deleted while it's still being written to.
-rwxr-xr-xdotfiles/common/.local/bin/cron/log-cleanup11
1 files changed, 9 insertions, 2 deletions
diff --git a/dotfiles/common/.local/bin/cron/log-cleanup b/dotfiles/common/.local/bin/cron/log-cleanup
index e8d6ac4..b2d1fbb 100755
--- a/dotfiles/common/.local/bin/cron/log-cleanup
+++ b/dotfiles/common/.local/bin/cron/log-cleanup
@@ -19,8 +19,15 @@ cutoff=$(date -d "$DAYS days ago" +%Y%m%d)
for f in "$LOG_DIR"/*.log; do
[ -f "$f" ] || continue
- # Extract YYYY-MM-DD from filename; skip files without a date
- filedate=$(basename "$f" | grep -oP '\d{4}-\d{2}-\d{2}' | head -1)
+ # Extract YYYY-MM-DD from filename, or fall back to an embedded
+ # _<10-digit-epoch>_ (used by hyprland-runtime logs which lack a
+ # human-readable date in the filename). Skip files with neither.
+ name=$(basename "$f")
+ filedate=$(echo "$name" | grep -oP '\d{4}-\d{2}-\d{2}' | head -1)
+ if [ -z "$filedate" ]; then
+ epoch=$(echo "$name" | grep -oP '_\K[0-9]{10}(?=_)' | head -1)
+ [ -n "$epoch" ] && filedate=$(date -d "@$epoch" +%Y-%m-%d 2>/dev/null)
+ fi
[ -n "$filedate" ] || continue
# Skip files still being written to (modified in the last 24h).
# This prevents deleting active logs from long-running sessions.