Solved

Command which acts on the contents of logs

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

757 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

19 Experts available now in Live!

Get 1:1 Help Now