🔍 深度清理与验证

卸载完成后,做一次深度检查。确认没有残留进程在跑、没有端口被占用、没有服务在偷偷自启。这是专业运维的基本功。

检查残留进程

# macOS / Linux
ps aux | grep -i openclaw

# 更精确地搜索(排除 grep 自身)
ps aux | grep -i "[o]penclaw"

如果有结果,说明还有 OpenClaw 相关进程在运行。记下 PID,用 kill <PID> 终止。

检查端口占用

# macOS
lsof -iTCP -sTCP:LISTEN -P -n | grep -i openclaw

# Linux
ss -lptn | grep -i openclaw

# 或者用 lsof(需要 root)
sudo lsof -iTCP -sTCP:LISTEN -P -n | grep -i openclaw

OpenClaw 默认可能使用的端口包括 18789、18791、18792、19789、5353(UDP)。检查这些端口是否还在被占用。

检查服务自启配置

macOS — launchctl

launchctl list | grep -iE "openclaw|clawdbot|moltbot|gateway"

Linux — systemd

# 用户级
systemctl --user list-units --all | grep -iE "openclaw|clawdbot|gateway"

# 系统级
systemctl list-units --all | grep -iE "openclaw|clawdbot|gateway"

通用 — crontab

crontab -l | grep -iE "openclaw|clawdbot|gateway"

检查环境变量

确认 shell 配置文件中没有残留的 OpenClaw 环境变量:

# 检查常见的 shell 配置文件
grep -i openclaw ~/.bashrc ~/.zshrc ~/.bash_profile ~/.profile 2>/dev/null

如果找到了,手动编辑对应文件删除相关行。

✅ 验证卸载成功

运行以下命令,如果全部提示"找不到"或无输出,恭喜你,OpenClaw 已经完全从系统中移除了:

# CLI 是否还在
which openclaw
# 应该输出:openclaw not found

# 配置目录是否还在
ls ~/.openclaw 2>/dev/null
# 应该输出:No such file or directory

# 进程是否还在
ps aux | grep "[o]penclaw"
# 应该无输出

# 服务是否还在
systemctl --user status openclaw-gateway 2>/dev/null
# 应该提示找不到

全部通过?🎉 你的系统已经干干净净了。