[K12OSN] Purging ALL users

Scott Sherrill scott at hancock.k12.mi.us
Mon Oct 25 19:44:33 UTC 2004

>3) is there any way to kill ALL users processes without 
>bunkfidarnaking up the server and without rebooting?


We use a script that was posted to the list long long ago called 
unclean.  I can credit the author (but thanks whomever you are).

Here's the script:

#! /usr/bin/env python2

import os

names = ['root', 'bin', 'daemon', 'adm', 'lp',
          'sync', 'shutdown', 'halt', 'mail',
          'news', 'uucp', 'operator', 'games',
          'gopher', 'ftp', 'nobody', 'vcsa',
          'mailnull', 'rpm', 'ntp', 'rpc', 'xfs',
          'rpcuser', 'nfsnobody', 'nscd', 'ident',
          'radvd', 'named', 'pcap', 'amanda',
          'gdm', 'scott']

os.system('ps aux > .ps.dat')
lines = open('.ps.dat').readlines()
for line in lines[1:]:
     if line.split()[0] not in names:
         os.system('kill -9 %s' % line.split()[1])

I run unclean 1/night by cron to clean up all the cruft before the 
next day begins.  Just put whatever usernames NOT to kill in the list 
above and off ya go.


More information about the K12OSN mailing list