Created
March 11, 2012 18:52
-
-
Save jacobk/2017662 to your computer and use it in GitHub Desktop.
Perform an exorcism and rid your systems of foul daemons...
This file contains hidden or 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
#!/usr/bin/env bash | |
FORCE=false | |
while getopts f o; do | |
case $o in | |
f) FORCE=true;; | |
esac | |
done | |
echo "Analyzing your system..." | |
user=`whoami` | |
topproc=`top -user $user -o cpu -stats pid,command,cpu -n 1 -l 3 | tail -n 1` | |
set -- $topproc | |
echo "$2 is consuming $3% CPU" | |
$FORCE || read -p "Kill it? [N]: " -r | |
if $FORCE || [[ $REPLY =~ ^[Yy]$ ]]; then | |
echo "Killing pid $1" | |
`kill -9 $1` | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment