Detect and clean up orphaned browser processes left behind when OpenClaw Gateway restarts.
OpenClaw's browser tool uses Playwright to launch Chrome/Chromium/Firefox. When the Gateway
restarts (update, crash, manual restart), these browser child processes become orphans — their
parent PID changes to 1 (init/systemd). They keep running, consuming memory, and accumulate
over days.
This tool is safe by default:
--kill~/.openclaw/browser/ in the command line/tmp/openclaw/zombie-browser-cleanup.logbash
bash <skill_dir>/scripts/cleanup-zombie-browsers.sh
Output example:
text
Found 8 OpenClaw browser processes, 5 are zombies (1200MB total)
ZOMBIE: PID=66301 PPID=1 age=3d 2h mem=388MB
ZOMBIE: PID=152356 PPID=1 age=2d 4h mem=168MB
...
Run with --kill to terminate these zombie processes
bash
bash <skill_dir>/scripts/cleanup-zombie-browsers.sh --kill
OptionDefaultDescription--killoffActually terminate zombie processes--min-age N3600 (1h)Only target processes older than N seconds--grace N10Seconds between SIGTERM and SIGKILL--jsonoffOutput as JSON (for programmatic use)--log PATH``/tmp/openclaw/zombie-browser-cleanup.logLog file location--pattern STR``.openclaw/browser/Pattern to identify OpenClaw browsers
Add to your health check script or heartbeat:
bash
# Detect and report (no kill)
bash /path/to/cleanup-zombie-browsers.sh
# Auto-clean with safety margin (processes must be >2 hours old)
bash /path/to/cleanup-zombie-browsers.sh --kill --min-age 7200
A process is classified as a zombie browser if ALL of these are true:
.openclaw/browser/ (the user-data-dir used by OpenClaw)--min-age threshold (prevents killing browsers that are actively initializing)If ANY condition is not met, the process is skipped.
PlatformStatusNotesLinuxFullUses /proc filesystem for precise detectionmacOSFullUses ps with etime parsingWindowsNot yetPlanned (PowerShell-based)
All Playwright-supported browsers with OpenClaw user-data-dir:
CodeMeaning0No zombies found, or zombies cleaned (--kill mode)1Zombies detected but not killed (detect mode)