Your OpenClaw installation has been running great for weeks. Then suddenly: everything feels slow. Commands take forever. Cron jobs start failing. You check top and see openclaw-gateway eating 60-70% CPU doing... nothing?
I just fixed this exact problem today. Here's what causes it and how to fix it in about 5 minutes.
The Symptoms
You might notice some or all of these:
- High CPU usage — openclaw-gateway consuming 60-70% CPU constantly
- Slow responses — even simple messages take 10-30 seconds to get a reply, when it should be instant
- Memory creep — memory usage at 20% (1.6GB) when it should be ~5%
- Lock timeout errors in your cron jobs
If you're seeing this error, keep reading — your sessions.json file is almost certainly bloated.
The Root Cause: Session Bloat
Every time a cron job runs in OpenClaw, it creates a new entry in sessions.json with a full copy of the skillsSnapshot field. Each snapshot is about 3.7KB of JSON.
🔍 The Math
4,767 cron runs × 3.7KB = 21MB of redundant data
Every session operation must read/parse this entire 28MB file.
When the file gets too large:
- Every read/write operation takes longer
- Write operations timeout before completing
- Orphaned
.tmpfiles accumulate - Lock acquisition fails, causing cron job crashes
Step 1: Diagnose the Problem
First, confirm this is actually your issue. Run these commands:
1Check CPU usage
Look for openclaw-gateway at 60%+ CPU.
2Check sessions.json size
If it's over 10MB, you've found the problem.
3Count session files
Thousands of session files? Time to clean up.
4Check for stale temp files
If you see .tmp files, these are failed write operations that never completed.
Step 2: The 5-Minute Fix
⚠️ Before You Start
These commands will clean up old session data. Active sessions won't be affected, but you may lose history for sessions older than 7 days.
1Remove stale temp files
2Delete old session files (>7 days)
3Remove skillsSnapshot bloat from cron runs
This is the big one. Run this Node.js script to strip redundant data:
4Restart the gateway
The gateway will auto-restart. Give it 10-15 seconds.
5Verify the fix
The Results
Here's what happened when I ran this fix today:
| Metric | Before | After |
|---|---|---|
| CPU Usage | 60-70% | 19% |
| Memory | 20% (1.6GB) | 4.5% (360MB) |
| sessions.json | 28MB | 2.5MB |
| Load Average | 0.81 | 0.31 |
| Response Time | Slow | Instant |
✅ That's It
Your OpenClaw should now be running fast again. The whole fix takes about 5 minutes.
Quick Health Check Command
Save this as a script for easy monitoring:
Prevention: Keep It Clean
To prevent this from happening again:
- Monitor sessions.json size — if it exceeds 10MB, run cleanup
- Set up a weekly cron job to delete session files older than 7 days
- Watch for symptoms — slow responses and high CPU are early warning signs
📋 Signs You Need Cleanup
- sessions.json over 10MB
- CPU consistently above 40% when idle
- Session lock timeout errors
- Multiple .tmp files in the sessions folder
Want More OpenClaw Tips?
Join Vibe Coding Academy for troubleshooting guides, performance tips, and a community of builders running AI agents.
Join the AcademyKey Takeaways
- Session bloat is the #1 cause of sluggish OpenClaw performance
- The
skillsSnapshotfield accumulates in cron run entries - Clean up with a simple Node.js script + file deletion
- Monitor sessions.json size — stay under 10MB
- The fix takes 5 minutes and dramatically improves performance