The other day, I was sitting in a coffee shop working, when I looked down to find that 25% of my battery was left.

I looked at my Activity Monitor and saw that the time machine process was going at 90% for a while (as long as I was watching it).

Are there any apps that can notify me if a process is at a certain level for a certain amount of time?


You could run a script like this every minute with cron or launchd:


current=$(ps -erco %cpu,command | tail -n+2 | sed 's/^ *//')
echo "$current" > $prefix$(date +%s)
a=($prefix*); for ((i=0;i<=${#a[@]}-3;i++)); do rm "${a[i]}"; done
[[ $(awk '{s+=$1}END{printf "%i",s}' <<< "$current") -lt $cpulimit ]] && exit
averages=$(awk '{cpu=$1;sub(/[^ ]+ /,"");a[$0]+=cpu;c[$0]++}END{for(i in a){printf "%.1f %s\n",a[i]/c[$0],i}}' $prefix* | sort -rn)
if [[ $(awk '{s+=$1}END{printf "%i",s}' <<< "$averages") -ge $cpulimit ]]; then
    terminal-notifier -title "CPU use" -message "$(head -n5 <<< "$averages" | paste -sd / -)"

If the average CPU use in the last three samples is over 50%, it uses terminal-notifier to display the processes that used the most CPU.

You could also use MenuMeters to display total CPU use in the menu bar:

Or run a script like this with GeekTool:

for i in {1..4}; do ps -erco %cpu,command | tail -n+2; sleep 1; done | sed 's/^ *//' | grep -v GeekTool | awk '{cpu=$1;sub(/[^ ]+ /,"");a[$0]+=cpu;c[$0]++}END{for(i in a){printf "%.1f %s\n",a[i]/c[$0],i}}' | sort -rn

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .