Skip to content

Instantly share code, notes, and snippets.

@akarca
Last active January 8, 2024 19:02
Show Gist options
  • Save akarca/606586955fe3796a041c1460133070e4 to your computer and use it in GitHub Desktop.
Save akarca/606586955fe3796a041c1460133070e4 to your computer and use it in GitHub Desktop.
Kill CMFSyncAgent and sharingd processes if they demand high cpu
#!/bin/bash
#
# Sometimes my mac's fans run loud because CMFSyncAgent and sharingd processes are consuming high amount of CPU.
# This script watches the processes and kills them. Stop this script if you want to use AirDrop
# Kill CMFSyncAgent if it consumes more than 70% cpu
# Kill sharingd if it consumes more than 30% cpu
#
while true
do
ps aux | grep CMFSyncAgent | awk '$3>70 {print $2}' | xargs kill -9
ps aux | grep sharingd | awk '$3>30 {print $2}' | xargs kill -9
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment