![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to replace all string instances found by find+grep | umen | Shell Programming and Scripting | 0 | 12-06-2007 03:52 AM |
| Checking the header and trailer for a given string and if not found, exit out of the | er_ashu | UNIX for Dummies Questions & Answers | 2 | 11-08-2007 09:55 AM |
| Search for string and display those NOT found | John Rihn | Shell Programming and Scripting | 17 | 05-22-2007 08:22 AM |
| Display only found string | Cranie | Shell Programming and Scripting | 5 | 01-21-2007 07:01 PM |
| Recursive Search and replace only when found string | umen | Shell Programming and Scripting | 1 | 05-07-2006 01:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Stopping tail -f when certain string found?
Hi,
I need to monitor a log file for a certain string ("Phase 2 ended") which indicates that the job which creates the log file has finished loading its data file. Once the string "Phase 2 ended" is found in the log file I would then like to stop checking that log and check to see if another logfile has been started - and start the whole process over. Here's what I have so far ... Code:
#!/bin/ksh # Get name of the newest logfile LogFile=`ls -tr /path/logfilename_* | tail -1` if grep 'Phase 2 ended' $LogFile then echo ---------- echo "File has finished processing. No file currently being loaded." echo ---------- else echo echo ---------- echo "File still being loaded. Will monitor progress, watch for \"Phase 2 ended\" message." echo ---------- #Show all 'Phase' messages in log file so far... grep 'Phase' $LogFile #Keep checking so 'Phase 2 ended' message can be seen... tail -f $VAULogFile | grep Phase fi I think I need a while read, so I can stop the tail -f and then loop to the next log file (if one yet exists) but I don't know how to do it. Could one of you experts please point me in the right direction? Many thanks -- Jake |
|
||||
|
Quote:
Thanks also, Chr15. I didn't really want to resort to a kill if possible but I appreciate your help. Thanks. |
![]() |
| Bookmarks |
| Tags |
| looping, tail -f, while read |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|