Created
September 8, 2011 20:23
-
-
Save jcsalterego/1204570 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Throw this in your crontab. | |
# | |
# https://twitter.com/#!/manton/status/111893189971017729 | |
# | |
BOSS=boss@example.org | |
CPU_THRESHOLD=1500 | |
kill_xcode_and_email () { | |
kill -9 $(ps aux | grep /[X]code | awk '{print $2}'); | |
if [ -n "$BOSS" ]; then | |
echo "I'm taking the rest of the day off." \ | |
| mail -s "Because of XCode..." $BOSS; | |
fi | |
} | |
xcodeline=$(ps aux | grep /[X]code) | |
if [ -n "$xcodeline" ]; then | |
cpu=$(echo $xcodeline | awk '{print $3}' | sed -e 's/\..*//g') | |
if [ "$cpu" -gt $CPU_THRESHOLD ]; then | |
kill_xcode_and_email | |
exit 0 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment