← 返回
未分类 中文

Disk Cleanup

Automated disk space cleanup and maintenance for OpenClaw deployments. Cleans 12 categories: memory SQLite orphan tmp files, SQLite VACUUM, Docker dangling i...
自动化磁盘空间清理与维护,适用于OpenClaw部署。涵盖12类清理项:内存、SQLite孤立文件、临时文件、SQLite VACUUM、Docker悬空镜像等。
yagebin79386 yagebin79386 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 464
下载
💾 0
安装
1
版本
#latest

概述

Disk Cleanup

Automated disk space recovery for OpenClaw deployments. Covers 12 cleanup categories that OpenClaw does not handle natively (as of 2026.3.13).

What OpenClaw Already Handles (skip these)

  • Session store: session.maintenance config (pruneAfter, maxEntries, rotateBytes)
  • Sandbox containers: sandbox.prune config (idleHours, maxAgeDays)
  • Context pruning: contextPruning config (cache-ttl mode)

What This Skill Handles (the gaps)

#CategoryTypical GrowthTrigger
-------------------------------------
1Memory SQLite .tmp-* orphansHundreds of MB from failed reindexAlways
2Memory SQLite VACUUMFragmentation after heavy use--aggressive
3Docker images/volumes/build cacheGB from sandbox rebuildsAlways
4Gateway logs (/tmp/openclaw/*.log)Grows daily>3 days old
5/tmp OpenClaw temp filesPatrol/board/cron artifacts>24h old
6Workspace .prebind.* backupsHundreds of MB per backup>7 days old
7Delivery queue old entriesGrows with message volume>7 days old
8systemd journalGB on default VPS configs>500MB
9npm/yarn/pnpm/bun/prisma/node-gyp cacheGB from skill/plugin installs>100MB
10Rotated syslogs + btmpSSH brute-force logs on public VPSAlways
11Git workspace .gitAuto-commit growth (board-move etc.)>200MB
12QMD/migration artifactsStale after backend switchAuto-detected

Quick Start

Run directly:

# Preview what would be cleaned (safe, no deletions)
bash scripts/disk-cleanup.sh --dry-run

# Normal cleanup
bash scripts/disk-cleanup.sh

# Deep cleanup: includes SQLite VACUUM + aggressive git gc
bash scripts/disk-cleanup.sh --aggressive

# Cron mode: only outputs summary line
bash scripts/disk-cleanup.sh --quiet

Schedule as Cron Job

Weekly Sunday 04:00 CET (recommended):

Use the cron tool:
  schedule: { kind: "cron", expr: "0 3 * * 0", tz: "Europe/Luxembourg" }
  payload: { kind: "agentTurn", message: "Run disk cleanup: bash scripts/disk-cleanup.sh --aggressive --quiet. Report results." }
  sessionTarget: "isolated"

Or integrate into an existing infra-health-check script by adding a disk usage threshold trigger:

DISK_PCT=$(df / --output=pcent | tail -1 | tr -d ' %')
if [ "$DISK_PCT" -ge 85 ]; then
  bash /path/to/disk-cleanup.sh --quiet
fi
if [ "$DISK_PCT" -ge 90 ]; then
  bash /path/to/disk-cleanup.sh --aggressive --quiet
fi

Environment Variables

VariableDefaultDescription
--------------------------------
OPENCLAW_HOME~/.openclawOpenClaw state directory
OPENCLAW_WORKSPACE$(pwd)Agent workspace root

Exit Codes

  • 0 — Success (cleaned or nothing to clean)
  • 1 — Error during cleanup

Output Format

Last line is machine-parseable:

CLEAN|0|0B|44%          # Nothing cleaned
CLEANED|5|1.2GB|67%     # 5 actions, freed 1.2GB, now at 67%

Safety

  • --dry-run previews all actions without deleting
  • SQLite VACUUM only on --aggressive and only when fragmentation ≥5%
  • Docker prune only removes dangling (untagged) images; named images are safe
  • btmp is truncated (not deleted) — system expects the file to exist
  • Journal vacuum installs a persistent 500MB limit to prevent regrowth
  • Git gc uses --auto by default; --aggressive only with flag

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 08:14 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,813
it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 31,100
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装后可防止您和您的用户受到提示注入、数据泄露及恶意行为的侵害。
★ 116 📥 31,033