#!/bin/sh # @(#) logmon.shutdown - Revision 1.1 - 01/17/97 # # Shutdown the logmon daemon. # # ============================================================================= # Andrea Whitlock, Mobius Software Services # whitlock@mobius-soft.com # # Bug reports, questions, and suggestions should be emailed to: # mobius@mobius-soft.com # # This software is provided under the terms of the GNU copyleft # (ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0), without a warranty # of any kind. Use at your own risk. # ============================================================================= # # # configure me ################################################################ # # part 1 # # set the path to the logmon server log LOGMONLOG=/home/logmon/log/logmon.log # # part 2 # # set the logmon server port PORT=3003 # # part 3 # # set the path to the tac command. the tac command will cat a file backwards. # it is part of the GNU text utilties (ftp://prep.ai.mit.edu/pub/gnu/textutils*) TAC=/usr/local/bin/gtac # # part 4 # # ps needs to list all processes and the format needs to be: # user pid whatever [whatever [...]] # linux #PS="ps -aux" # hpux, solaris PS="ps -eaf" # # configure me end ############################################################ pid=`$TAC $LOGMONLOG | grep pid | head -1 | awk '{ print $4 }'` kill -15 $pid childpids=`$TAC $LOGMONLOG | awk ' /^------/ { exit } { if ($1 == "child") openpidlist[$2] = $2 if ($1 == "closing" && $5 == "child") closepidlist[$6] = $6 } END { for (p in openpidlist) { if (!closepidlist[p]) printf("%s ", p) } }'` if [ "$childpids" ] then for pid in $childpids do kill -15 $pid done fi $PS | grep "logmon $PORT" | grep -v grep | while read user pid junk do kill -15 $pid done