#!/usr/bin/csh -f # # Name: # stop_check_keywords # # Purpose: # stop the 'check_keywords' program # # Usage: # stop_check_keywords spec|imag # # Arguments: # None # # Exit values: # 0 = normal completion # 1 = unable to kill process # # Modification history: # 2002-Oct-04 GDW Original version # 2010-Sep-21 jlyke Adapted for OSIRIS # 2021-Mar-17 jlyke Updated for new host #----------------------------------------------------------------------- # set defaults... set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd spec|imag" # verify args... if ( $#argv != 1 ) then printf "$usage\n" exit 1 endif switch ($1) case "S*": case "s*": set M = "s" set mode = "spec" breaksw case "I*": case "i*": set M = "i" set mode = "imag" breaksw default: printf "$usage\n" exit 1 breaksw endsw # build mode-dependent variables set search = "check_keywords ${mode}" # check for running process... #/usr/bin/ps -ax | grep -v $cmd | grep -v grep | grep "$search" set process = ( `/usr/bin/ps -ax | grep -v $cmd | grep -v grep | grep "$search" | awk '{print $1}'` ) if ( $#process == 0 ) then printf "No check_keywords to kill...\n" exit endif # kill running process... printf "stopping ${search}...PID $process..." \kill -9 $process # verify kill... #/usr/bin/ps -ax | grep -v $cmd | grep -v grep | grep "$search" set process = ( `/usr/bin/ps -ax | grep -v $cmd | grep -v grep | grep "$search" | awk '{print $1}'` ) if ( $#process == 0 ) then printf "OK\n" exit else printf "ERROR\n" set owner = ( `/usr/bin/ps -eo "user pid" | grep $process` ) printf "Owner PID\n" printf "$owner\n" exit 1 endif