#!/bin/sh HOSTN=`hostname|cut -f1 -d.` PST=/tmp/clean_often.$HOSTN.$$.$RANDOM rm -f $PST 2>/dev/null # only call "ps" once, since the process table changes very fast and we might otherwise # report inconsistent information ps -efw | egrep -v '^UID' > $PST # also filter out netstat, since mozilla and galeon frequently generate defunct netstat children LIST_OF_DEFUNCT_PPID=`cat $PST|fgrep defunct |fgrep -v grep|fgrep -v netstat|perl -p -e's/^\s+//;@a=split/\s+/;$_=$a[2]."\n"'` for p in $LIST_OF_DEFUNCT_PPID do cat $PST | fgrep $p done | sort -u rm $PST