#!/bin/bash # Script clean_tmp_media.sh: Don dep cache media, browser va file tam thoi # Dam bao khong dung den cac thu muc chua auth/tokens cua Google hay NotebookLM echo "==========================================" echo "BÁO CÁO DỌN DẸP CACHE HỆ THỐNG (IT & AI)" echo "==========================================" echo "Thời gian thực thi: $(date '+%Y-%m-%d %H:%M:%S %Z')" echo "Host: $(hostname)" echo "" # Ghi nhan dung luong truoc khi don DISK_BEFORE=$(df -h / | awk 'NR==2 {print $3}') # 1. Don dep browser binaries va cache runtime cua Puppeteer/Playwright echo "[1/5] Dọn dẹp cache trình duyệt (Playwright, Puppeteer)..." rm -rf /root/.cache/ms-playwright rm -rf /root/.cache/puppeteer rm -rf /root/.hermes/profiles/*/home/.cache/puppeteer 2>/dev/null rm -rf /root/.hermes/profiles/*/home/.cache/ms-playwright 2>/dev/null # 2. Xoa cac tep tin media va file tam trong thu muc /tmp va /var/tmp echo "[2/5] Dọn dẹp file tạm tại /tmp và /var/tmp..." find /tmp /var/tmp -type f \( -name "*.mp4" -o -name "*.png" -o -name "*.jpg" -o -name "*.jpeg" -o -name "*.webm" -o -name "*.gif" \) -exec rm -f {} + 2>/dev/null find /tmp -type f -name "com.google.Chrome.*" -exec rm -rf {} + 2>/dev/null find /tmp -type f -name "hermes-snap-*.sh" -exec rm -f {} + 2>/dev/null find /tmp -type d -name "playwright-artifacts-*" -exec rm -rf {} + 2>/dev/null find /tmp -type d -name "playwright_chromiumdev_profile-*" -exec rm -rf {} + 2>/dev/null find /tmp -type d -name "puppeteer_dev_chrome_profile-*" -exec rm -rf {} + 2>/dev/null rm -rf /tmp/node-compile-cache 2>/dev/null # 3. Xoa cache va anh chup man hinh/audio tam thoi cua tat ca profile Hermes echo "[3/5] Dọn dẹp media cache của các profile Hermes..." rm -rf /root/.hermes/audio_cache/* 2>/dev/null rm -rf /root/.hermes/profiles/*/audio_cache/* 2>/dev/null rm -rf /root/.hermes/profiles/*/cache/vision/* 2>/dev/null rm -rf /root/.hermes/profiles/*/cache/web/* 2>/dev/null rm -rf /root/.hermes/profiles/*/cache/screenshots/* 2>/dev/null rm -rf /root/.hermes/profiles/*/cache/videos/* 2>/dev/null rm -rf /root/.hermes/profiles/*/cache/images/* 2>/dev/null rm -rf /root/.hermes/profiles/*/cache/terminal-output/* 2>/dev/null # 4. Xoa cache global cua Hermes echo "[4/5] Dọn dẹp cache global Hermes..." rm -f /root/.hermes/cache/lark_login.png /root/.hermes/cache/images/* /root/.hermes/cache/screenshots/* 2>/dev/null # 5. Xoa cache package manager da qua han (tren 15 ngay) echo "[5/5] Dọn dẹp cache Python quá hạn (> 15 ngày)..." find /root/.cache/uv/archive-v0 -atime +15 -type f -exec rm -f {} + 2>/dev/null find /root/.cache/pip -atime +15 -type f -exec rm -f {} + 2>/dev/null # Ghi nhan dung luong sau khi don DISK_AFTER=$(df -h / | awk 'NR==2 {print $3}') DISK_AVAIL=$(df -h / | awk 'NR==2 {print $4}') DISK_PCT=$(df -h / | awk 'NR==2 {print $5}') echo "" echo "==========================================" echo "KẾT QUẢ THỰC HIỆN:" echo "• Trạng thái: Hoàn tất thành công" echo "• Dung lượng sử dụng trước dọn: $DISK_BEFORE" echo "• Dung lượng sử dụng sau dọn: $DISK_AFTER" echo "• Dung lượng khả dụng hiện tại: $DISK_AVAIL (đã dùng $DISK_PCT)" echo "=========================================="