It sounds like you're working with a daemon's log file and if so you'll need to be careful. If you overlay the open log file, you'll stop seeing updates to the file as you will have unlinked the open file from the directory and replaced it with a static file that you marked up with hash (#) signs.
I think you have two choices:
1) use tail -f to read the log file and pipe the output through grep or awk to do what you need. This is probably easiest.
2) if your log file has timestamps then you can run your search periodically. With each run save the last time stamp in the log file, tuck it away in a /tmp file or something, and only process messages in the log that have a timestamp greater than the last one saved.
Hi ,
I am trying a script which takes user input userid . I am stuck how to check whether that is a valid user id or not in the audit log files. My code is :
cd $CCP_AUDIT
cat * > /export/home/$USR/l***/files
echo "UserId:\c"
read UserId
#Date Function
echo "DATE : \c"
read xxx
I... (7 Replies)
I have a huge file and want to separate it into several subsets.
The file looks like:
C1 C2 C3 C4 ... (variable names)
1 ....
2 ....
3 ....
:
22 ....
23 ....
I want to separate the huge file using the column 1, which has numbers from 1 to 23 (but there are different amount of... (8 Replies)
I have a key file
$ cat klist
5 N:8855 CASA VERDE ROAD :32827 :ORLAND
5 N:585 MOLLY LANE :30189 :WOODST
5 N:320 NINA ROAD :32304 :TALLAH
and a data file, see example of the line below:
N:RT 15 & N 7TH STREET :17837 :U SAVE
I need to search by key (2nd field) from klist... (6 Replies)
Hi all,
I have the below script to get input but i cannot get grep to work.
input1.txt
AAAAAAAAG
input2.txt
>gi|184009.1| LEAFY-like |AAAAAAAAGSGGGDHLPY
However, when i use grep -f input1.txt input2.txt
i cannot get any output matches (note that the match is underlined).
Is it... (8 Replies)
So this is what I'm trying to do:
I have a file called registry.txt which has a list of registry entries I want to search for.
I have another file called inctrl.txt on which I want to perform the search on.
Here's the example contents of registry.txt
SOFTWARE\Microsoft\Security... (3 Replies)
Hello everybody,
I have been searching it, but it seems I am unable to find the correct information, that s why I am asking you guys, hoping somebody get an idea.
Here is my problem :
I want a script to loop until a string is identified in a log file.
Here is the script :
#!/bin/sh... (5 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I need to search through the users home directories for keywords, display them. The code listed below will show... (7 Replies)
Hello -
I am running a script that is outputting to a log. Let call it output.log
I would like to monitor that log until the line "Build Successful" is found.
I think I would need to use the grep command.
How would I do that in a loop?
Thanks
Marty (1 Reply)
Hello,
I have built the following script to check if processes supplied by the argument are running or not.
#!/bin/bash
PROCLIST=$1
PROCESS="0"
ERROR_PROCS=""
IFS='+'
read -ra ADDR <<< "$PROCLIST"
for PROC in "${ADDR}"; do
if ; then
PROCESS=1
... (9 Replies)
Discussion started by: nms
9 Replies
LEARN ABOUT DEBIAN
logtop
LOGTOP(1) General Commands Manual LOGTOP(1)NAME
logtop - Realtime log line rate analyser
SYNOPSIS
logtop [OPTIONS]
DESCRIPTION
logtop is a System Administrator tool analyzing line rate on stdin.
It reads on stdin and print a constantly updated result
displaying, in columns:
Line number, count, frequency, and the actual line.
$ tail -f FILE | logtop
is the friendly version of:
$ watch 'tail FILE | sort | uniq -c | sort -gr'
OPTIONS -s, --size=K
Only keep K lines in memory, instead of 10000.
-q, --quiet
Do not display a live view of the data, only display a top at exit.
-l, --line-by-line=K
Print result line by line, in a machine friendly format, K is the number of result to print per line.
Line by line format is : [%d %f %s ]*
%d : Number of occurences
%f : Frequency of apparition
%s : String (Control chars replaced by dots.
-i, --interval=K
Interval between graphical updates, in seconds. Defaults to 1.
-h, --help
Show summary of options.
-v, --version
Show version of program.
EXAMPLES
Here are some logtop usage examples.
tail -f cache.log | grep -o "HIT|MISS" | logtop
Realtime hit / miss ratio on some caching software log file.
tail -f access.log | cut -d' ' -f1 | logtop -s 10000
Realtime most querying IPs on your server, as long as log lines in access.log starts with the client IP.
tail -f access.log | cut -d' ' -f7 | logtop -s 10000
Realtime most requested web pages in a NCSA like log file.
cat auth.log | grep -v "CRON" | grep -o ": .*" | logtop -q -s 100000
Display a one-shot simple analyse of your auth.log.
SEE ALSO watch(1)AUTHOR
logtop was written by Julien Palard.
This manual page was written by Julien Palard <julien@palard.fr>, for the Debian project (and may be used by others).
April 16, 2011 LOGTOP(1)