Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to trap a string in a log file

Posted on 2009-04-02
1
Medium Priority
?
273 Views
Last Modified: 2013-12-06
We have an application that takes a while to start-up. We don't make it available until it is completely back up. The only way to tell that it is up is to tail the log file and wait until we see the "Server startup completed" string. The application is started by running a shell script that we created and we would like to modify it so that the script monitors the log file, and when the "Server startup completed" string is encountered, the script will also make the app available.

Any help in figuring out how to do this would be greatly appreciated.
0
Comment
Question by:Jorge Fraser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

Accepted Solution

by:
flow01 earned 2000 total points
ID: 24054252
in ksh
nr_startup_messages=0
while [[ $nr_startup_messages -eq 0 ]] ; do
   nr_startup_messages=`tail -n logfile | grep -c 'Server startup completed'`
   if [ $nr_startup_messages -gt 0 ]
      then
       echo `date` Server startup completed
  else
       echo 'date` Server startup not completed
  fi
  sleep 300 ## wait 5 minutes
done
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question