Skip to content

Instantly share code, notes, and snippets.

@jacobk
Created March 11, 2012 18:52
Show Gist options
  • Save jacobk/2017662 to your computer and use it in GitHub Desktop.
Save jacobk/2017662 to your computer and use it in GitHub Desktop.
Perform an exorcism and rid your systems of foul daemons...
#!/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