![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 By the way, I'm using the Korn shell. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
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 |
|
#3
|
|||
|
|||
|
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.
|
|||
| Google The UNIX and Linux Forums |