需先通过 brew services list 定位关机助手服务,再执行 brew services stop 和 uninstall 彻底移除;若未被 Homebrew 管理,则手动卸载并删除 ~/Library/LaunchAgents/ 或 /Library/LaunchDaemons/ 中可疑 plist 文件,最后清除可执行文件、配置目录及 shell 初始化文件中的调用语句。

苹果电脑上通过Homebrew安装的关机助手任务(如 homebrew-services 托管的守护进程或自定义 launchd plist)若持续在后台触发关机、休眠或提醒行为,需精准定位并移除对应服务,否则可能造成误关机或系统异常。
确认关机助手服务名称
打开终端,执行命令查看当前由 Homebrew 管理的所有运行中服务:brew services list
在输出列表中查找含 shutdown、poweroff、sleep、auto-off 或明显非官方工具名(如 mac-shutdown-daemon、powerguard)的服务项。注意区分 Homebrew 官方公式(如 redis、postgresql)与第三方自制脚本——后者才是目标。
这一步不能跳过。如果直接删 plist 文件却没停服务,launchd 会在下次启动时自动重载它。
停止并卸载 Homebrew 托管的服务
若服务名称为 my-shutdown-helper(以实际查到的为准),执行以下两步:
brew services stop my-shutdown-helper → brew services uninstall my-shutdown-helper
执行后终端应返回 Successfully stopped my-shutdown-helper 和 Uninstalled my-shutdown-helper。若提示 No such service,说明该服务未被 brew services 管理,需进入下一步手动清理。
手动删除残留的 launchd 配置文件
方法一:检查用户级启动代理
执行:ls ~/Library/LaunchAgents/ | grep -i "shut\|power\|sleep"
找到匹配文件(如 com.example.autoshutdown.plist),用 launchctl unload -w ~/Library/LaunchAgents/com.example.autoshutdown.plist 卸载,再用 rm ~/Library/LaunchAgents/com.example.autoshutdown.plist 删除文件。
方法二:检查系统级守护进程(需管理员权限)
执行:sudo ls /Library/LaunchDaemons/ | grep -i "shut\|power"
若发现可疑 plist,先运行 sudo launchctl unload -w /Library/LaunchDaemons/xxx.plist,再执行 sudo rm /Library/LaunchDaemons/xxx.plist。
【警告】不要删除任何以 com.apple. 开头的 plist 文件,误删会导致系统功能异常。
清空相关可执行文件与配置目录
第一步:定位主程序路径
运行 which shutdown-helper 或 which autooff(替换为实际命令名)。若返回路径(如 /opt/homebrew/bin/shutdown-helper),直接删除:rm /opt/homebrew/bin/shutdown-helper
第二步:删除配置与数据目录
常见位置包括:
• ~/Library/Application Support/shutdown-helper/
• ~/.config/shutdown-helper/
• /opt/homebrew/etc/shutdown-helper/
逐一检查是否存在,存在则执行 rm -rf 彻底清除。
第三步:检查 shell 初始化文件是否注入自动调用
运行 grep -n "shutdown\|poweroff" ~/.zshrc ~/.zprofile ~/.bash_profile 2>/dev/null,若输出某行含类似 shutdown-helper --daemon & 的语句,用文本编辑器打开对应文件,删掉该行并保存。


















