Solved

How to trap a string in a log file

Posted on 2009-04-02
1
269 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
1 Comment
 
LVL 20

Accepted Solution

by:
flow01 earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

832 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