#!/usr/bin/env bash #------------------------------------------------------------------------------ # call: kill_exec exec_name # # kills executable exec_name, assumptions: executable "$exec" from time to time # updates file name "$exec.$$" , where $$ is PID of the process # corresponding to the running executable and $exec is the executable name # # hmm... the assumptions are quite limited... #------------------------------------------------------------------------------ # used to show time stamp # necessary to use an alias non-interactively shopt -s expand_aliases name=`basename $0` alias tsecho='echo \[ $name \] `date "+%Y/%m/%d %H:%M:%S"` = ' exec=$1 tsecho list $exec from ls ls -latr --full-time $exec.* tsecho list $exec from ps ps -U `id -un` uwww | grep $exec export pid=`ls -tr $exec.* | tail -n 1 | awk -F. '{print $NF}'` tsecho kill $exec, pid = $pid kill -9 $pid exit 0