Hi,
I am trying to write a script to do monitoring kind of stuff,
requirement - when a server is given a start it updates a file called server.log, I need to keep on grepping the word "Running" and as soon as it comes , script should be exited with the message , "Server came up successfully else it shoud wait for "Running" untill 7 minuts, and then should time out with the message "script timed out"
My idea is to use tail -f server.log | grep "Running" , but im not sure how will this exit because tail will wait for the input into server.log
for timinig out I think best I can use is sleep
so it shoud be
while ( i < 420 )
do
tail -f server.log | grep "Running" //(the problematic area)
if [ $? == 0 ]
then
echo "Server came up succesfully"
exit 0
i++
done
echo "script timed out"
PLease suggest. if my logic is wrong or i have placed wrong commands.