LoginSignup
8
8

More than 5 years have passed since last update.

Mac OS X で Growl が暴走したときに再起動

Last updated at Posted at 2012-03-16

Skypeとかが新Growlに対応してなくて?たまに暴走する。
冬は膝の上ぽかぽかでいいんだけど健康的じゃないので再起動する。面倒なので自動でする。

適当に cron とかにいれた。

growl_restart
#!/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

(追記。 cut だと pid の桁数が grep の pid と異なるときうまくとれないから awk に変えた

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8