#!/bin/sh

kill_all () {
  ps xw -U `id -un` | grep -v grep | grep $1 | while read pid ignore; do
    kill $pid
  done 
}

#PIDFILE=pidfile
PID=`ps x -o pid,command | grep start.pl | grep -v grep | awk '{print $1}'`

if [ "$PID" != "" ] ; then
  kill $PID
else
  echo "It seems that spectrum monitoring is not running."
  exit 0
fi

kill_all start.pl
kill_all monitoring.pl
kill_all scanBand.pl
kill_all scanDiapason.pl
sleep 6
kill_all SpectrumServer

#rm -rf $PIDFILE
