Files
openclaw/tools/pi-disk-autoclean.sh
Clawd Bot ca9b510922 chore: align with upstream openclaw/openclaw and overlay local additions
- Reset master to upstream/main (16,697 commits)
- Overlay 2,271 local-only files (skills, tools, workspace, configs, apps)
- Restore IDENTITY.md and USER.md templates
- Build verified, gateway running, Discord working

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 07:40:46 +01:00

36 lines
1022 B
Bash

#!/bin/bash
# Pi Disk Auto-Cleanup (Silent - no spam)
# Runs when disk >85%, cleans silently
PI_HOST="100.76.212.107"
THRESHOLD=85
LOG="/home/alex/clawd/logs/pi-autoclean.log"
# Check Pi disk
USAGE=$(ssh alex@$PI_HOST "df -h / | tail -1 | awk '{print \$5}' | sed 's/%//'")
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "[$(date)] Pi disk at $USAGE% - auto-cleaning..." >> "$LOG"
# Auto-cleanup (safe operations only)
ssh alex@$PI_HOST "
# Vacuum journal (keep 7 days)
sudo journalctl --vacuum-time=7d >/dev/null 2>&1
# Clean APT cache
sudo apt-get clean >/dev/null 2>&1
# Remove old kernels (keep current + 1)
sudo apt-get autoremove -y >/dev/null 2>&1
"
# Check new usage
NEW_USAGE=$(ssh alex@$PI_HOST "df -h / | tail -1 | awk '{print \$5}' | sed 's/%//'")
FREED=$((USAGE - NEW_USAGE))
echo "[$(date)] Cleaned: $USAGE% → $NEW_USAGE% (freed ${FREED}%)" >> "$LOG"
else
# Silent - all good
exit 0
fi