Created
February 11, 2014 23:35
-
-
Save relsqui/8946668 to your computer and use it in GitHub Desktop.
Kill processes with UID > 1024.
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/sh | |
MAX_PROTECTED_UID=1024 | |
ps auxn | tail -n +2 | while read uid pid process; do | |
if [ "$uid" -gt "$MAX_PROTECTED_UID" ]; then | |
kill $pid | |
if ps $pid > /dev/null; then | |
kill -9 $pid | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment