Skip to content

Instantly share code, notes, and snippets.

@sotarok
Created December 6, 2011 07:23
Show Gist options
  • Save sotarok/1437185 to your computer and use it in GitHub Desktop.
Save sotarok/1437185 to your computer and use it in GitHub Desktop.
Mac OS X で Growl が暴走したときに再起動 ref: http://qiita.com/items/1302
#!/bin/bash
PID=$(ps ax | grep Growl.app | grep -v grep | awk '{print $1};')
test -z "$PID" && open -j -a Growl && echo "Growl restarted on $(date) :: pid not found ($PID)" >> /tmp/growl_restart.log && exit
CPU_USAGE=$(top -pid $PID -l 2 -s 5 -stats cpu | tail -n1 | cut -d"." -f1)
if test $CPU_USAGE -gt 80
then
killall Growl
open -j -a Growl
echo "Growl restarted on $(date) :: pid=$PID" >> /tmp/growl_restart.log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment