@@ -0,0 +1,701 @@
+#!/usr/bin/env python%0Aimport os, sys%0A%0Apasswd = %5Bx.split(':') for x in open('/etc/passwd').readlines()%5D%0A%0Adef renice_user(user):%0A    user = user.rstrip('+')%0A    v = %5Bx for x in passwd if user in x%5B2%5D%5D%0A    if len(v) %3E 1:%0A        print(%22user %25s does not uniquely determine user%22%25user)%0A    elif len(v) == 0:%0A        print(%22no such user %25s%22%25user)%0A    else:%0A        cmd = %22sudo renice -n 19 -u %25s%22%25v%5B0%5D%5B0%5D%0A        print(cmd)%0A        os.system(cmd)%0A%0Aif len(sys.argv) %3E 1:%0A    n = int(sys.argv%5B1%5D)%0Aelse:%0A    n = 5%0A%0Afor x in os.popen(%22ps aux %7C sort -nrk 3,3%22).readlines():%0A    v = x.split()%0A    user = v%5B0%5D%0A    if user not in %5B'root', 'salvus'%5D:%0A       renice_user(user)%0A    n -= 1%0A    if n %3C= 0:%0A        break%0A

add a script: smc-nice-auto.py [n] to renice the n worst users