?
Solved

Command which acts on the contents of logs

Posted on 2000-05-05
3
Medium Priority
?
279 Views
Last Modified: 2010-04-20
Hello All.
 I am sure I have seen this somewhere, but I cannot find it again. Is there a program that watches the end of a file as it grows (like a log file), and executes a user defined script when certain text appears in the log. If not, how can this be done.

Thanks in advance,
Nicholas Waltham
0
Comment
Question by:nwaltham
3 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2782543
"tail -f some-file" watches the end of a file, continuously showing it's content as new info is added. You could pipe that to a script to watch for a specific string and it could act accordingly.
0
 
LVL 15

Accepted Solution

by:
samri earned 100 total points
ID: 2787266
nwaltham,

Just some addition (in addtion to jlevie comment :)

tail -f some-file | egrep "some pattern" | you-home-made-script.sh

Maybe you are looking for "login" in /var/adm/message

tail -f /var/adm/message | egrep "login" | logwatcher.sh

should do.  and don't forget that you need to write the "lgowatcher.sh" script yourself.

:)
0
 
LVL 2

Expert Comment

by:EatEmAndSmile
ID: 2788589
Exactly. The "cut" command will provide the filter to grab the interesting part of the text you need.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

807 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