Chrome MCP

HE
henuwangkai
Community
👁 8·💰 ~0 USD·📅 Published Mar 24, 2026·📖 1 min read

安全清理 Chrome MCP 旧进程脚本,自动保留最新进程只杀旧的

1. Chrome MCP 进程安全清理脚本

安全清理 Chrome MCP 旧进程脚本,自动保留最新进程只杀旧的

Prompt

#!/bin/bash
# kill-old-chrome-mcp.sh
# 只杀旧的 Chrome MCP 进程,保留最新的(当前 Claude Code session 的)
#
# 用法:bash ~/scripts/kill-old-chrome-mcp.sh

PIDS=$(ps aux | grep "[c]hrome-devtools-mcp" | grep -v watchdog | grep -v "npm exec" | awk '{print $2}')

if [ -z "$PIDS" ]; then
    echo "没有找到 chrome-devtools-mcp 进程"
    exit 0
fi

COUNT=$(echo "$PIDS" | wc -l | tr -d ' ')

if [ "$COUNT" -le 1 ]; then
    echo "只有 1 个 Chrome MCP 进程 (PID: $PIDS),无需清理"
    exit 0
fi

# 保留最新的(PID最大的),杀掉其他所有
NEWEST=$(echo "$PIDS" | sort -n | tail -1)
OLD_PIDS=$(echo "$PIDS" | sort -n | head -n -1)

echo "发现 $COUNT 个 Chrome MCP 进程"
echo "保留最新: PID $NEWEST"
echo "杀掉旧的: $OLD_PIDS"

for pid in $OLD_PIDS; do
    # 同时杀掉关联的 npm exec 和 watchdog 进程
    PARENT_PIDS=$(ps aux | grep -E "npm exec.*chrome-devtools|watchdog.*parent-pid=$pid" | grep -v grep | awk '{print $2}')
    kill $pid $PARENT_PIDS 2>/dev/null
    echo "  已杀: PID $pid (及关联进程)"
done

echo "✅ 清理完成,保留 PID $NEWEST"

Discussion

Discussion

Sign in to join the discussion.
MC
Maya Chen·2 hours ago

Tried this with a marketing ops workflow and it cut prompt iteration time by half. The Prompt section is especially reusable.

LW
Leo Wang·Yesterday

Would love a follow-up showing how you adapted this for team use.

  • We forked it internally
  • Replaced the model with Claude Sonnet
  • Saved the structure as a reusable playbook

Related Assets

Related Assets

Other assets published by the same creator.

Back to home