A small collection of utility scripts used with Clawdbot (cron jobs, housekeeping, and helpers).
Notes
- These scripts are not auto-trading / auto-execution. They generate outputs for humans (or for Clawdbot to relay).
- Most scripts are designed to be run by cron/Clawdbot. When run manually, you may need to set env vars.
Polls Gmail INBOX via IMAP and prints new messages.
- State file:
~/.openclaw/state/gmail-poll.json(trackslast_uidper account/folder) - Output:
- No new mail → prints exactly
NO_REPLY - New mail → prints one line per email:
"<sender> — <subject>"
- No new mail → prints exactly
Environment variables:
- Required:
GMAIL_USER– full Gmail addressGMAIL_APP_PASSWORD– Google App Password (16 chars, no spaces)
- Optional:
GMAIL_FOLDER– defaultINBOXGMAIL_MAX– max items per run, default10
Example:
GMAIL_USER="you@gmail.com" \
GMAIL_APP_PASSWORD="xxxx xxxx xxxx xxxx" \
python3 scripts/gmail-poll.pyImplementation detail:
- Gmail IMAP UID range search can be quirky; the script uses
UID SEARCH ALLthen filtersuid > last_uidclient-side to avoid duplicate notifications.
A lightweight market scan (intended for running every ~30 minutes during market hours).
- US market data: stooq (free, delayed)
- HK market data: IBKR Client Portal Gateway (optional; via
https://localhost:5005) - Output: short watchlist (max 4 symbols) + simple risk-managed “plan” (entry/stop/take/size)
- It prints
NO_REPLYoutside the configured market time windows (unless--force).
Usage:
node scripts/market-scan.mjs --market=us
node scripts/market-scan.mjs --market=hk
# Debug
node scripts/market-scan.mjs --market=hk --verbose
# Run even outside market hours
node scripts/market-scan.mjs --market=us --forceNotes for HK:
- Requires IBKR Client Portal Gateway running locally and authenticated.
- If not connected, the script prints
NO_REPLYby default (cron-friendly).
Disk-safety cleanup for NoMachine/NX caches that can grow very large.
- Checks
~/.nxsize; if below threshold → exits quietly. - Threshold: 5GB (hard-coded)
- Logs to:
~/Documents/HealthChecks/nx-autoclean.log
What it does (high level):
- Kills user-side NoMachine components (
nxnode,nxrunner) to release open files - Removes session artifacts under
~/.nx/node/*,~/.nx/temp/*,~/.nx/cache/*, and old logs/pids - Optionally clears
~/Documents/NoMachine/*
Run manually:
bash scripts/nx-autoclean.shHousekeeping for Clawdbot logs.
- Deletes old daily gateway logs under
/tmp/clawdbot(default: 14 days) - Rotates + gzips large launchd stdout/stderr logs under
~/.openclaw/logsgateway.log,gateway.err.log
- Prunes rotated gz files (default: 30 days)
Environment variables (optional):
DAYS_TMP(default14)DAYS_ROTATED(default30)MAX_BYTES(default200000000= 200MB)
Run manually:
bash scripts/openclaw-log-cleanup.shWrapper around whisper.cpp (whisper-cli) to transcribe an audio file and print plain text to stdout.
- Default CLI path:
/opt/homebrew/bin/whisper-cli(override withWHISPER_CLI) - Default model:
~/.openclaw/models/whisper/ggml-small.bin(override withWHISPER_CPP_MODEL) - Default language: auto (override with
WHISPER_LANG)
It also handles common macOS audio formats:
- If the audio is not wav/mp3/flac/ogg, it will attempt conversion to wav via
/usr/bin/afconvert.
Usage:
bash scripts/whisper-transcribe.sh /path/to/audio.caf
# Example: force language
WHISPER_LANG=en bash scripts/whisper-transcribe.sh /path/to/audio.m4aThese scripts help you back up and restore Clawdbot data:
scripts/openclaw-backup.sh– rsync mirror backup to~/Backups/clawdbot/latestscripts/openclaw-restore-latest.sh– restore from the latest mirror (overwrites current files)scripts/openclaw-snapshot.sh– manual point-in-time snapshot (tar.gz) before risky upgrades- See also:
scripts/README.backup.md
Quick usage:
# Latest mirror backup
scripts/openclaw-backup.sh
# Manual snapshot (recommended before core changes)
scripts/openclaw-snapshot.sh
# Restore from latest mirror (DANGEROUS: overwrites current data)
scripts/openclaw-restore-latest.shInternal utility scripts (add a license here if you intend to open-source).
- This repo is now mirrored under:
/Users/sunny/.openclaw/workspace/clawd-scripts - GitHub remote (
origin) is set to:git@github.com:alchip/clawd-scripts.git - Purpose: keep legacy scripts available in the current OpenClaw workspace and sync updates to GitHub from here.