#!/bin/sh # These processes get killed with -9 PROCESS_LIST="doug broadcaster dsp_manager" # Insert host names here if you want the script to rsh out to each of them and run this script SUPPORT_HOSTS="" ############################################################ # # ATTENTION: Do not change code under this line # ############################################################ # Set colors BAR_COLOR="" NUM_COLOR="" if [ "$OSTYPE" = "solaris" ] then RESET="\c" else RESET="-n " fi # Determine which O/S we are running on MACHINE_OS="`uname -s`" if [ "$MACHINE_OS" = "Linux" ] then if [ -e "/etc/redhat-release" ] then MACHINE_OS_WITH_VERSION="${MACHINE_OS}_`cut -f5 -d " " /etc/redhat-release`" fi fi # Print run header echo echo "$BAR_COLOR==================================================================================" echo $RESET echo "Starting $0 @ `date`" # If requested, rsh to specified machine and run this script if [ $# -gt 0 ] then echo " Remote Host: $1" echo " Handing off to $1..." rsh $1 $0 exit else echo -e " Local Host: \t\t`hostname`" fi # Get username MY_USER=$USER if [ "$OSTYPE" = "solaris" ] then MY_UID=`/usr/xpg4/bin/id -u` else MY_UID=`id -u` fi echo -e " User ID, Username: \t$MY_UID, $MY_USER" #DEBUG echo if [ "$MACHINE_OS_WITH_VERSION" = "Linux_5.2" ] then PS_ARGS="aux" else if [ "$OSTYPE" = "linux" ] then PS_ARGS="-u $MY_UID" else if [ "$OSTYPE" = "linux-gnu" ] then PS_ARGS="-u $MY_UID" else if [ "$OSTYPE" = "solaris" ] then PS_ARGS="-u $MY_UID" else PS_ARGS="-u $MY_UID" fi fi fi fi #echo #echo "#### DEBUG ####" #echo "OSTYPE : $OSTYPE" #echo "USER : $MY_USER" #echo "UID : $MY_UID" #echo "PS_ARGS : $PS_ARGS" #echo "#### DEBUG ####" #echo # Kill specified list of processes for x in $PROCESS_LIST do MY_PROCESSES=`ps $PS_ARGS | grep $x | grep -v grep | grep -v $0 | awk '{print $1}'` echo -e " Target $SIMULATION_NAME Processes: $NUM_COLOR\t`echo $MY_PROCESSES | wc -w`\t ($x)" echo $RESET # Kill specified process IDs for i in $MY_PROCESSES do echo " > kill -9 $i" `kill -9 $i` done done # Remove any shared memory, semaphores, or message queues that exist for this user if [ "$MACHINE_OS" = "Linux" ] then MY_MEMORY=`ipcs -mp | grep " $MY_USER "| grep "^[0-9]" | cut -c1-30 | sed "s/^\ *//g" | cut -f1 -d' '` MY_SEMAPHORES=`ipcs -s | grep " $MY_USER " | grep "^[0-9]" | cut -c11-20 | sed "s/^\ *//g" | cut -f1 -d' '` MY_MQUEUES=`ipcs -qp | grep " $MY_USER " | grep "^[0-9]" | cut -c1-30 | sed "s/^\ *//g" | cut -f1 -d' '` else MY_MEMORY=`ipcs | grep " $MY_USER " | grep "^m" | cut -c2-30 | sed "s/^\ *//g" | cut -f1 -d' '` MY_SEMAPHORES=`ipcs | grep " $MY_USER " | grep "^s" | cut -c2-30 | sed "s/^\ *//g" | cut -f1 -d' '` MY_MQUEUES=`ipcs | grep " $MY_USER " | grep "^q" | cut -c2-30 | sed "s/^\ *//g" | cut -f1 -d' '` fi echo -e " Target Shared Memory : $NUM_COLOR\t`echo $MY_MEMORY | wc -w`" echo $RESET for i in $MY_MEMORY do if [ "$MACHINE_OS" = "Linux" ] then echo -e -n " > ipcrm shm $i\t" ipcrm shm $i else echo -e -n " > ipcrm -m $i\t" ipcrm -m $i fi done echo -e " Target Semaphores : $NUM_COLOR\t`echo $MY_SEMAPHORES | wc -w`" echo $RESET for i in $MY_SEMAPHORES do if [ "$MACHINE_OS" = "Linux" ] then echo " > ipcrm sem $i" ipcrm sem $i else echo " > ipcrm -s $i" ipcrm -s $i fi done echo -e " Target Message Queues: $NUM_COLOR\t`echo $MY_MQUEUES | wc -w`" echo $RESET for i in $MY_MQUEUES do if [ "$MACHINE_OS" = "Linux" ] then echo " > ipcrm msg $i" ipcrm msg $i else echo " > ipcrm -q $i" ipcrm -q $i fi done # Kill processes on specified support hosts for i in $SUPPORT_HOSTS do $0 $i done # Print run footer echo echo "Finished $0 @ `date`" echo "$BAR_COLOR==================================================================================" echo $RESET echo # End of script