The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
appears 4 or more time nickg UNIX for Dummies Questions & Answers 0 10-19-2007 01:00 PM
scp error code after successful transfer - $? appears incorrect badtea Shell Programming and Scripting 5 06-21-2007 07:27 PM
Sort - only one field appears in output? miwinter UNIX for Dummies Questions & Answers 1 07-24-2006 07:47 AM
Power M'ment OW Utilities appears selected when deselected etobgra UNIX for Advanced & Expert Users 0 04-20-2005 07:14 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-19-2008
Registered User
 

Join Date: Feb 2008
Posts: 15
grep'ing a file until a certain message appears

Hello,

I'm writing a script that will automate the launch of some services on my AIX machine. However, some services are dependent on the successful startup of others. When I start these services manually, I usually just check a log file until I see a message that confirms a successful startup. So, I figure I can integrate this into my script but I'm not sure what the best way to do it is. I was thinking something like this:
Code:
while [ `tail -f /path/to/log/file | grep "PATTERN"` -ne "0" ]; do
done
but that seems cumbersome for the system (not to mention the fact that I don't think it's working). What would be the best approach here? Thanks for your help.

By the way, I'm using the Korn shell.
Reply With Quote
Forum Sponsor
  #2  
Old 05-19-2008
Registered User
 

Join Date: Dec 2006
Posts: 28
Quote:
Originally Posted by pallak7 View Post
Hello,

I'm writing a script that will automate the launch of some services on my AIX machine. However, some services are dependent on the successful startup of others. When I start these services manually, I usually just check a log file until I see a message that confirms a successful startup. So, I figure I can integrate this into my script but I'm not sure what the best way to do it is. I was thinking something like this:
Code:
while [ `tail -f /path/to/log/file | grep "PATTERN"` -ne "0" ]; do
done
but that seems cumbersome for the system (not to mention the fact that I don't think it's working). What would be the best approach here? Thanks for your help.

By the way, I'm using the Korn shell.

As your concern is to check if related service is Up or not running I think you have to deal with "ps -ef"

So if you want to run your script after being sure that apache is Up you can do it like this

If [`ps -ef|egrep -i "http|apache"|wc -l` -gt 1 ]
then
.........
fi


Hope this helps
Reply With Quote
  #3  
Old 05-19-2008
Registered User
 

Join Date: Feb 2008
Posts: 15
Well, I would do that except for it's possible for the process to start up unhealthily (couldn't think of another word). This means that the process is alive but not functioning the way it's supposed to. In order for me to check if the process is alive and healthy, I have to check the log file. Also, it takes ~20 secs for the process to come up completely so I feel like the checking has to be done in a loop; I can't just check once and then move on.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0