Skip to content

Instantly share code, notes, and snippets.

@relsqui
Created February 11, 2014 23:35
Show Gist options
  • Save relsqui/8946668 to your computer and use it in GitHub Desktop.
Save relsqui/8946668 to your computer and use it in GitHub Desktop.
Kill processes with UID > 1024.
#!/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