Solved

Command which acts on the contents of logs

Posted on 2000-05-05
3
238 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 50 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

813 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

13 Experts available now in Live!

Get 1:1 Help Now