Skip to content

Instantly share code, notes, and snippets.

@schultzisaiah
Created May 6, 2020 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schultzisaiah/756d87613b1069b3e5bc5a68157504a3 to your computer and use it in GitHub Desktop.
Save schultzisaiah/756d87613b1069b3e5bc5a68157504a3 to your computer and use it in GitHub Desktop.
Auto kill a resource-hogging process
# AUTO-KILL iCoreService using more than 60% CPU
# run as super user (sudo ./auto-kill-process.sh)
while true
do
PID=$(ps aux | grep 'iCoreService' | grep -v grep | awk '{ if ($3 >= 60.0) { print $2 } }' | head -n 1)
if [ ! -z "$PID" ]
then
kill -9 $PID
date >> iCoreService-kills.log
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment