Created
February 5, 2018 02:23
-
-
Save Fang-Li/0145b10add8535338bcac00687e984d9 to your computer and use it in GitHub Desktop.
Kill cpu occupy more than 80% of the process
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
| #!/bin/bash | |
| #killer.sh | |
| export PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin | |
| while true; | |
| do | |
| ps axf -o "pid %cpu command" |grep -v bashd| awk '{if($2>=80.0) print $1}' | while read procid | |
| do | |
| kill -9 $procid | |
| done | |
| sleep 3 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment