From 7999b9ad79a5aba6b12be73a938c823fc5b329e8 Mon Sep 17 00:00:00 2001 From: Spacedio Date: Sun, 24 May 2026 21:07:04 -0400 Subject: Reorganization of files. --- system/usr/system-maintenance | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 system/usr/system-maintenance (limited to 'system/usr/system-maintenance') diff --git a/system/usr/system-maintenance b/system/usr/system-maintenance new file mode 100755 index 0000000..d2918c6 --- /dev/null +++ b/system/usr/system-maintenance @@ -0,0 +1,29 @@ +#!/bin/bash + +# Configuration +MARKER_FILE="/var/log/last_maintenance_timestamp" +LOG_OUT="/var/log/maintenance.log" +# 604800 seconds = 7 days +INTERVAL=604800 + +# Get last run time or 0 if file doesn't exist +LAST_RUN=$(stat -c %Y "$MARKER_FILE" 2>/dev/null || echo 0) +CURRENT_TIME=$(date +%s) + +if [ $((CURRENT_TIME - LAST_RUN)) -ge $INTERVAL ]; then + { + echo "-------------------------------------------" + echo "[$(date)] Starting weekly maintenance..." + + # 1. Trim SSD + /usr/sbin/fstrim -v / + + # 2. Run Backup (Example) + # /usr/local/bin/backup.sh 2>&1 + + # Update timestamp marker + touch "$MARKER_FILE" + + echo "[$(date)] Maintenance complete." + } >> "$LOG_OUT" 2>&1 +fi -- cgit v1.2.3