Solved

How to trap a string in a log file

Posted on 2009-04-02
1
267 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now