Results 1 to 3 of 3
I'm writing a script that will automate the startup of a few services but some actions are dependent upon the successful completion of others. I can check for this by ...
- 05-15-2008 #1
Inspecting a log file until a certain message appears
I'm writing a script that will automate the startup of a few services but some actions are dependent upon the successful completion of others. I can check for this by scanning the log file until the message I'm looking for appears but I can't seem to work this part into my script. I've tried:
just to idle until the correct message appears but it is just hanging forever even though I know the message has been written to the log.Code:while [ `tail -f /path/to/log/file | grep "PATTERN"` -ne "0" ]; do done
What's the best way to fix this?
- 05-16-2008 #2Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
I am guessing but your code looks like a tight busy loop.
You should add some sleep. May be this is what is causing the hang.
- 05-17-2008 #3
you are asking to much to your box
tail -f is meant to run foreground until you stop it, so if you put it in a while loop your computer will be like "wow its DoomsDay today!!". the instructions after tail -f wont run.
you can use perl to avoid this though. perl will handle tail -f correctly so you wont have it hanging.Linux and me it's a love story


Reply With Quote