<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.xxx.killKeyboardCN</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/xxx/
kill_zh-hans-cn.sh</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>9</integer>
</dict>
<dict>
<key>Hour</key>
<integer>13</integer>
</dict>
</array>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
放到/Users/xxx/Library/LaunchAgents/ 文件夹下,launchctl bootstrap /Users/xxx/Library/LaunchAgents/xx.plist 。每天早上和中午上班前会自动执行一次
kill_zh-hans-cn.shkill_zh-hans-cn.sh 内容:
#!/bin/bash
process_ids=$(ps aux | grep -i 'zh-Hans-CN' | grep -v 'grep' | awk '{print $2}')
for pid in $process_ids; do
echo "Killing process ID: $pid"
kill -9 $pid
done
就再也没卡死过了