[K12OSN] Script for CRON Job to Cleanup Leftover Processes
Charles Hale
support at 499pc.net
Mon Oct 25 20:12:45 UTC 2004
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
More information about the K12OSN
mailing list