mac一键关闭系统更新
将下述代码保存为disable_macos_update.sh
:
#!/bin/bash
echo "🛑 正在关闭系统自动更新..."
sudo softwareupdate --schedule off
echo "🔒 正在禁用自动下载和安装..."
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool false
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticallyInstallMacOSUpdates -bool false
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdate -bool false
sudo defaults write /Library/Preferences/com.apple.commerce AutoUpdateRestartRequired -bool false
echo "🌐 正在屏蔽更新服务器..."
sudo tee -a /etc/hosts > /dev/null <<EOF
# Block macOS Updates
127.0.0.1 swscan.apple.com
127.0.0.1 swdist.apple.com
127.0.0.1 swdownload.apple.com
127.0.0.1 swquery.apple.com
127.0.0.1 swcdn.apple.com
127.0.0.1 updates.cdn-apple.com
127.0.0.1 mesu.apple.com
127.0.0.1 appldnld.apple.com
127.0.0.1 osrecovery.apple.com
127.0.0.1 gdmf.apple.com
EOF
echo "✅ macOS 系统更新已彻底禁用!重启后生效。"
授权并运行:
chmod +x disable_macos_update.sh
sudo ./disable_macos_update.sh