🔍 深度清理與驗證

解除安裝完成後,做一次深度檢查。確認沒有殘留程序在跑、沒有連接埠被佔用、沒有服務在偷偷自啟。這是專業維運的基本功。

檢查殘留程序

# 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
# 應該提示找不到

全部通過?🎉 你的系統已經乾乾淨淨了。