[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[K12OSN] Script for CRON Job to Cleanup Leftover Processes



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.
 
 
Scott
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]