aboutsummaryrefslogtreecommitdiff
path: root/dotfiles
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
commit7e9f87d2279cb18ac1807bbd1d97c180cadce6e4 (patch)
tree32af8803b6d12a9ab83095263d8bc6a3bc28756b /dotfiles
parent048b09eb0c679f35f8939422df1bbfdea24ef82e (diff)
downloadarchsetup-7e9f87d2279cb18ac1807bbd1d97c180cadce6e4.tar.gz
archsetup-7e9f87d2279cb18ac1807bbd1d97c180cadce6e4.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.
Diffstat (limited to 'dotfiles')
-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.