OpenClaw 安全卸载指南:彻底清理,不留任何痕迹
OpenClaw 安全卸载指南:彻底清理,不留任何痕迹
本文将基于 OpenClaw 官方文档,详细介绍如何在各平台上完整卸载 OpenClaw,包括停止后台 Gateway 服务、清除数据目录、移除 CLI 工具,以及应对”CLI 已删但服务还在跑”等边缘情况的处理方法。
卸载前的重要准备
在执行任何删除操作前,请先考虑:
1. 备份你的数据
OpenClaw 的状态目录(默认 ~/.openclaw/)存储了:
- 配置文件(API Key、渠道配置、模型设置)
- 对话历史(会话记录)
- Workspace 文件(Agent 工作区)
- 技能安装记录
如果这些数据对你有价值,先备份:
1 | # macOS / Linux |
2. 确认卸载路径
OpenClaw 提供两条卸载路径:
| 情况 | 方式 |
|---|---|
openclaw 命令仍然可用 |
简便路径:使用内置卸载命令 |
| CLI 已删除、服务仍在运行 | 手动服务清理 |
简便路径(CLI 仍可用)
这是最推荐的方式,一条命令完成所有清理:
1 | openclaw uninstall |
如果需要非交互式自动化(例如在脚本中使用):
1 | openclaw uninstall --all --yes --non-interactive |
即使没有安装 OpenClaw,也可以用 npx 运行卸载器(它会临时下载最新版执行):
1 | npx -y openclaw uninstall --all --yes --non-interactive |
内置卸载命令完成的操作
- 停止并卸载 Gateway 后台服务(launchd / systemd / 计划任务)
- 删除状态目录
~/.openclaw/(含配置、会话历史、工作区) - 移除 CLI 全局包
手动分步卸载
如果你想分步控制卸载过程,或者内置命令无法使用,可以按以下步骤手动操作。
步骤 1:停止 Gateway 服务
1 | openclaw gateway stop |
步骤 2:卸载 Gateway 后台服务
1 | openclaw gateway uninstall |
这一步会从系统服务管理器(launchd / systemd / schtasks)中删除 OpenClaw Gateway 的服务定义。
步骤 3:删除状态目录和配置
1 | # macOS / Linux |
1 | # Windows PowerShell |
如果你使用了自定义配置文件路径(
OPENCLAW_CONFIG_PATH环境变量),还需要单独删除该文件。
步骤 4:删除 Workspace(可选)
Workspace 目录包含 Agent 的工作文件(代码、生成文档等):
1 | rm -rf ~/.openclaw/workspace |
步骤 5:移除 CLI
根据当初的安装方式选择对应的卸载命令:
1 | # 使用 npm 安装的 |
步骤 6:删除 macOS 应用(如已安装)
1 | rm -rf /Applications/OpenClaw.app |
手动清理残留服务(CLI 已删除的情况)
如果你已经删除了 openclaw 命令,但 Gateway 服务还在后台运行(会在系统登录时自动启动),按以下方法手动清理。
macOS(launchd)
默认服务标签为 ai.openclaw.gateway(如果使用了 profile,标签格式为 ai.openclaw.<profile>):
1 | # 停止并卸载服务 |
如果存在旧版遗留的
com.openclaw.*标签,也需要一并清理:
1
2 launchctl bootout gui/$UID/com.openclaw.gateway 2>/dev/null
rm -f ~/Library/LaunchAgents/com.openclaw.gateway.plist 2>/dev/null
Linux(systemd)
默认服务名为 openclaw-gateway.service(如果使用了 profile,格式为 openclaw-gateway-<profile>.service):
1 | systemctl --user disable --now openclaw-gateway.service |
Windows(计划任务)
默认任务名为 OpenClaw Gateway(如果使用了 profile,名称为 OpenClaw Gateway (<profile>)):
1 | # 删除计划任务 |
使用了 Profile 的特殊情况
如果你曾使用 --profile 参数或 OPENCLAW_PROFILE 环境变量运行过多个 OpenClaw 实例,每个 profile 都有独立的状态目录(默认路径:~/.openclaw-<profile>)。
需要对每个 profile 重复执行步骤 3(删除状态目录)和对应服务的清理。
查看当前系统中存在的 profile 目录:
1 | ls -d ~/.openclaw* 2>/dev/null |
源码安装的额外步骤
如果你是通过 git clone 从源码运行 OpenClaw:
- 先执行上面的服务卸载步骤(步骤 1-2)——必须在删除仓库目录之前完成
- 删除仓库目录:
1
rm -rf ~/openclaw # 替换为你实际的路径
- 删除状态目录和 Workspace(步骤 3-4)
⚠️ 注意: 如果先删除了仓库目录再停止服务,服务脚本会找不到可执行文件,可能留下僵尸服务。务必先停止服务再删目录。
卸载完整性检查清单
执行完卸载后,逐条验证:
-
openclaw命令已不存在:which openclaw返回空 - Gateway 服务已停止:
openclaw doctor或检查进程 - 状态目录已删除:
ls ~/.openclaw返回 “No such file” - macOS:launchd plist 已删除
- Linux:systemd 服务文件已删除并 daemon-reload
- Windows:计划任务已删除
1 | # 快速验证(macOS / Linux) |
重新安装
如果之后想重新安装 OpenClaw,只需执行:
1 | curl -fsSL https://openclaw.ai/install.sh | bash |
之前备份的配置文件可以恢复到 ~/.openclaw/ 目录,Gateway 会自动识别。
参考资料:
- 官方卸载文档: https://docs.openclaw.ai/install/uninstall
- 安装文档: https://docs.openclaw.ai/install