bash script tail when string found do something

Okay, I have two scripts, the first one does some stuff, and comes to a point where it has this:

Right here it runs a quick script to start something that writes to a log file.

/usr/bin/tail -f ${pathVar}/nohup_${servVar}.out |
while read -r line
do
   [[ "$line" != *Server\ state\ changed\ to\ RUNNING* ]] && continue
        cd ${pathVar}
        ./markerReset
exit
done
exit

This calls another script that does basically the same thing:

Before this line it calls a script that starts something that prints to a log.

cd ${MSD}
/usr/bin/tail -f ${MSD}/nohup_${servVar}.out |
while read -r line
do
   [[ "$line" != *Server\ state\ changed\ to\ RUNNING* ]] && continue
        echo "Marker Reset Complete"
done
exit

My logic may be way off here, but what I need is the following:

The first script shuts down the two servers, then it cd's to a directory, deletes some directories and then re-creates them, then it starts the first server. Once that server prints the line in the first CODE box, it should run the second script, which runs another script that starts a different server. once the line in the second CODE box is printed, it should echo Marker Reset Complete, and then exit the script it's in, as well as then exit the first script.

Right now, it seems to run perfect until the end, then at the end it prints the marker reset complete line, but then it doesn't do anything for 20-30 seconds until it FINALLY exit's.

---------- Post updated at 02:05 PM ---------- Previous update was at 10:46 AM ----------

I'm sure this isn't the most efficient way to accomplish what I'm trying to do, but has anyone seen this issue before when after tailing a file and reading it for a line you get a long delay after the line is found and the script is supposed to go on tot he next step?

---------- Post updated 08-06-09 at 09:06 AM ---------- Previous update was 08-05-09 at 02:05 PM ----------

someone out there has to have an idea on this.

---------- Post updated at 02:50 PM ---------- Previous update was at 09:06 AM ----------

Here is my solution, not exactly the way I originally wanted it, but this runs much quicker and more efficiently.

testVar=0
counter=0
while [ $testVar -eq "0" ]
do
sleep 3
counter=$(( $counter + 1 ))
        if grep -q 'RUNNING' ${MSD}/nohup_${SERVER_NAME}.out
                then
                        echo "Reset Complete"
                        testVar="1"
        fi
        if [[ -n "${counter}" && ${counter} -gt 80 ]]
        then
                echo "Marker Reset timed out"
                exit
        fi
done
exit

used a similar version of that in both scripts.