乐于分享
好东西不私藏

OpenClaw 卸载与彻底清理指南(全平台)

OpenClaw 卸载与彻底清理指南(全平台)

OpenClaw 卸载与彻底清理指南(全平台)

OpenClaw(龙虾)卸载需按流程操作,才能彻底清除服务、配置、CLI及系统残留,以下是整理后的结构化卸载方案。

一、官方自动卸载(推荐,最简单)

通过官方脚本一键卸载核心组件,适合绝大多数场景。

# 交互式卸载(需手动确认)openclaw uninstall# 非交互式全自动卸载(推荐,无需确认)openclaw uninstall --all --yes --non-interactive# 若CLI已删除,用npx临时调用官方脚本npx -y openclaw uninstall --all --yes --non-interactive

说明:该命令会移除gateway服务、agent运行时、配置/状态、工作区等核心组件,但需完成后续“扫尾检查”才能彻底清理。

二、分步手动卸载(彻底可控)

按“停止服务→卸载启动项→删除数据→移除CLI”顺序操作,避免残留。

1. 停止Gateway服务

openclaw gateway stop

2. 卸载Gateway系统启动项

openclaw gateway uninstall

3. 删除状态、配置与工作区(核心清理)

# 删除主状态/配置目录(默认~/.openclaw)rm -rf "${OPENCLAW_STATE_DIR:-$HOME/.openclaw}"# 删除工作区rm -rf ~/.openclaw/workspace# 清理旧版本profile残留(可选)rm -rf ~/.openclaw-*

⚠️ 权限不足时加sudo谨慎使用rm -rf,避免误删系统文件

4. 卸载CLI/GUI(按安装方式选择)

包管理器安装(npm/pnpm/bun)

npm rm -g openclawpnpm remove -g openclawbun remove -g openclaw

macOS Homebrew安装

# 卸载CLIbrew uninstall openclaw-cli# 卸载带GUI的应用brew uninstall --cask openclaw

源码安装(git clone)

先执行openclaw gateway uninstall卸载服务,再手动删除源码目录,避免服务引用失效路径报错。

三、踩坑处理:强制卸载顽固残留

若卸载后Gateway仍后台运行/开机自启,按系统强制清理。

macOS

# 替换$UID为当前用户ID(可通过`id -u`查询)launchctl bootout gui/$UID/ai.openclaw.gateway# 删除启动代理配置rm -f ~/Library/LaunchAgents/ai.openclaw.gateway.plist# 旧版本可能为com.openclaw.gateway/com.clawdbot.gateway,需核对名称

Linux

# 用户级服务(常用)systemctl --user disable --now openclaw-gateway.servicerm -f ~/.config/systemd/user/openclaw-gateway.servicesystemctl --user daemon-reload# 系统级服务(需sudo)sudo systemctl disable --now openclaw-gateway.servicesudo rm -f /etc/systemd/system/openclaw-gateway.servicesudo systemctl daemon-reload

Windows(管理员PowerShell)

# 删除计划任务schtasks /Delete /F /TN "OpenClaw Gateway"# 删除网关启动脚本Remove-Item -Force "$env:USERPROFILE\.openclaw\gateway.cmd"

提示:不同版本服务名可能为openclaw/clawdbot/gateway,需逐一核对。

四、深度清理:进程/端口/系统项排查

卸载后执行以下命令,确认无残留。

1. 检查残留进程与监听端口(macOS/Linux)

# 查找OpenClaw进程ps aux | grep -i openclaw# 检查TCP监听端口lsof -iTCP -sTCP:LISTEN -P -n | grep -i openclawss -lptn | grep -i openclaw

2. 检查系统自启项

# Linux systemdsystemctl --user list-units | grep -i openclaw# macOS launchctllaunchctl list | grep -i openclaw# 检查定时任务crontab -l | grep -i openclaw

3. Docker容器卸载(环境隔离,无宿主机残留)

# 查找容器docker ps -a | grep openclaw# 强制删除容器docker rm -f <容器ID/名称># 删除镜像docker rmi <镜像ID/名称>

五、最终提醒(安全+备份)

  1. 1. 云服务器:卸载后若不再使用,及时取消云服务,避免二次收费;检查是否有OpenClaw相关套餐/Token自动续费。
  2. 2. API密钥安全:前往各模型厂商(OpenAI、Claude等)API后台,删除不再使用的密钥,防止泄露与盗刷。
  3. 3. 数据备份(可选):若需保留配置/聊天记录,卸载前备份~/.openclaw目录与workspace,下次安装可通过官方恢复功能还原。