Serach a keyword based on last updated


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Serach a keyword based on last updated
# 1  
Old 03-04-2013
Serach a keyword based on last updated

Hi,

Can you guys help in writing script based upon my requirement.

The requirement is :

Th script should poll or sniff an log file every minute or every second. The log file name is "license.txt"

In the log file if it founds "not valid" then it should send mail to a group.

the logic here is :

1) it should check log file only if it gets updated

2) Every time it should check in the log which is updated latest

3) The search shouldn't start from the beginning of the file.


Let me know if any details you need.
# 2  
Old 03-04-2013
Taking into account the time it takes to send, receive, pop, and read a mail msg, even if someone in that group, twiddling their thumbs, is constantly checking their mails, examining the log file every second is overkill, even per minute is too much. Five minutes might be a good interval. Do your log file lines/entries have time stamps?
# 3  
Old 03-05-2013
Hi Rudic,

Agreed. my intention was to check periodically and it is not yet decided to what are the time intervals the cronjob needs to check.

For now just think that its 5 minutes and yes my log file has timestamps, please find the log :

Mar 5 02:52:20 app21 info message received invalid license for the license number 21345.
Mar 5 02:52:49 app21 messages processed successfully
Mar 5 02:57:48 app21 info message received invalid license for the license number 732900.
Mar 5 02:58:50 app21 messages processed successfully
Mar 5 02:58:50 app21 messages processed successfully
# 4  
Old 03-05-2013
I was thinking about comparing time stamps between last run and actual run, but that might be too coarse a criterion.
Create a little awk script that picks the previous last line no. from a file, skips all lines up to that no., checks the lines to EOF, creating your mail text, and saves the last line from this run in above file for the next run.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to align/sort the column pairs of an csv file, based on keyword word specified in another file?

I have a csv file as shown below, xop_thy 80 avr_njk 50 str_nyu 60 avr_irt 70 str_nhj 60 avr_ngt 50 str_tgt 80 xop_nmg 50 xop_nth 40 cyv_gty 40 cop_thl 40 vir_tyk 80 vir_plo 20 vir_thk 40 ijk_yuc 70 cop_thy 70 ijk_yuc 80 irt_hgt 80 I need to align/sort the csv file based... (7 Replies)
Discussion started by: dineshkumarsrk
7 Replies

2. Shell Programming and Scripting

awk join lines based on keyword

Hello , I will need your help once again. I have the following file: cat file02.txt PATTERN XXX.YYY.ZZZ. 500 ROW01 aaa. 300 XS 14 ROW 45 29 AS XD.FD. PATTERN 500 ZZYN002 ROW gdf gsste ALT 267 fhhfe.ddgdg. PATTERN ERE.MAY. 280 PATTERRNTH 5000 rt.rt. ROW SO a 678 PATTERN... (2 Replies)
Discussion started by: alex2005
2 Replies

3. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies

4. Shell Programming and Scripting

Merge file lines based off of keyword

Hello Everyone, I have two files I created in a format similar to the ones found below (character position is important): File 1: 21 Cat Y N S Y Y N N FOUR LEGS TAIL WHISKERS 30 Dog N N 1 Y Y N N FOUR LEGS TAIL 33 Fish Y N 1 Y Y N N FINS 43 CAR Y N S Y Y N N WHEELS DOORS... (7 Replies)
Discussion started by: jl487
7 Replies

5. UNIX for Dummies Questions & Answers

Serach a pattern

Hi, I am trying to find a particular patter in multiple UNIX files (also contain system files,hidden files and normal files) i am now using CMD: egrep -ali 'pattern' * i am not getting the required result, i just need files path and finename Naveen (3 Replies)
Discussion started by: Naveen_5960
3 Replies

6. Shell Programming and Scripting

How to convert 2 column data into multiple columns based on a keyword in a row??

Hi Friends I have the following input data in 2 columns. SNo 1 I1 Value I2 Value I3 Value SNo 2 I4 Value I5 Value I6 Value I7 Value SNo 3 I8 Value I9 Value ............... ................ SNo N (1 Reply)
Discussion started by: ks_reddy
1 Replies

7. Shell Programming and Scripting

Extract lines of text based on a specific keyword

I regularly extract lines of text from files based on the presence of a particular keyword; I place the extracted lines into another text file. This takes about 2 hours to complete using the "sort" command then Kate's find & highlight facility. I've been reading the forum & googling and can find... (4 Replies)
Discussion started by: DionDeVille
4 Replies

8. Shell Programming and Scripting

pattern serach using grep

Frds I have to search for a string which is starting with brighton which will be first in the line of a text file test1.txt. The contents of test1.txt are file names like ----- brighton brighton_gt hst_brighton gst_brighton -------so many files------ --------- i have retrieve only... (3 Replies)
Discussion started by: KiranKumarKarre
3 Replies

9. Shell Programming and Scripting

Record count based on a keyword in the records

Hi, Am having files with many records, i need to count and display the number of records based on the keyword in one of the column of the records. for e.g THE FILE CONTAINS TWO RECORDS LIKE. 200903031143150 0 1236060795054357lessrv1 BSNLSERVICE1 BSNLSERVICE1 ... (4 Replies)
Discussion started by: aemunathan
4 Replies

10. UNIX for Advanced & Expert Users

Serach and delete

Hi, This is the format of the file that i have CompanyNumber Run Date: 8/3/2006 6:22:15PM Address: Person: A03120 SP SNNu 100 1 200 2 CompanyNumber ... (3 Replies)
Discussion started by: kkm_job
3 Replies
Login or Register to Ask a Question