diff options
Diffstat (limited to 'system/usr/system-maintenance')
| -rwxr-xr-x | system/usr/system-maintenance | 29 |
1 files changed, 29 insertions, 0 deletions
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 |
