LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   killing tail --pid=??? (https://www.linuxquestions.org/questions/linux-software-2/killing-tail-pid%3D-81777/)

DavidPhillips 08-13-2003 10:08 PM

killing tail --pid=???
 
Howdy!

I am working on a project where I know nothing about what I'm doing as usual. :)

So here goes..

I have a script the runs from another like this
Code:

$SCRIPTDIR/oblog Overwrite &
echo $! > $PIDDIR/oblog.pid

the script is like this
Code:

if [ "$1" = "Overwrite" ]; then
tail -f $DATADIR/$FNAME.raw |sed -e 's/^~...//' |grep -f $GREPFILE > $DATADIR/$FNAME.ob

I can close the script down like this
Code:

kill -1 `cat $PIDDIR/oblog.pid`

tail, sed, and grep are still running
I want to kill off tail so sed and grep will finish

Maybe some use of --pid with tail, I would need to pipe something to it to do that, not sure
some other signal maybe?
any ideas?

thanks,

crabboy 08-13-2003 10:48 PM

The only think I can think of off hand is to write a kill script that will kill the tail. Pass in the oblog PID
Code:

#!/bin/sh

IFS='
'

for i in `ps -ef | grep tail`; do
  ID=`echo $i | awk ' { print $3 } '`
  if [ $ID -eq $1 ]; then
      echo kill  `echo $i | awk ' { print $2 } '`
  fi
done

Remove the echo when you are ready to kill.


All times are GMT -5. The time now is 04:57 AM.