Solved

How to trap a string in a log file

Posted on 2009-04-02
1
270 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

830 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