script to constantly read the last 500 new logs in a log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to constantly read the last 500 new logs in a log file
# 1  
Old 05-07-2011
script to constantly read the last 500 new logs in a log file

Hello,

I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are generated in this file to write the last log into a new file lik /var/tmp/tmp1.log. So, if the logs keep popping up in the /var/adm/message, for every 500 of them there will one instance in /var/tmp/tmp1.log. But, it has to monitor for new logs. Let's say the script already read 500 logs, the count has to be for new logs occurence all the time. It should not consider previous logs that could have been in the /var/adm/messages before that it might have already read. Please give me some ideas.

Thank you,
# 2  
Old 05-07-2011
Quote:
Originally Posted by Pouchie1
Hello,
I would like to write a bash script...
Great! But it seems you forgot to include what you did already.

Please try to format your posts in a more readable way. Such monologue-style paragraphs are difficult to read.


Quote:
Originally Posted by Pouchie1
Hello,

I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are generated in this file to write the last log into a new file lik /var/tmp/tmp1.log. So, if the logs keep popping up in the /var/adm/message, for every 500 of them there will one instance in /var/tmp/tmp1.log. But, it has to monitor for new logs. Let's say the script already read 500 logs, the count has to be for new logs occurence all the time. It should not consider previous logs that could have been in the /var/adm/messages before that it might have already read. Please give me some ideas.

Thank you,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine first two words ( country name ) into one word in every line of log file with 500 records

United States 1.2.3.4 80 10 1563790914 1 1932454179 1.2.3.6 55517 11.1.2.1 55517 Italy 1.2.3.4 80 10 1563790914 1 1932454179 1.2.3.6 55517 11.1.2.1 55517 India 1.2.3.4 80 10 1563790914 1 1932454179 1.2.3.6 55517 11.1.2.1 55517 south Africa 1.2.3.4 80 10 1563790914 1... (9 Replies)
Discussion started by: arm
9 Replies

2. Shell Programming and Scripting

Script to read last 30mins logs

Hi All, I want to read the log file for last 30mins logs with time stamps. Am using below command but, it is not working for me awk -F - -vDT="$(date --date="30 minutes ago" "+%b %_d %H:%M:%S")" ' DT < $1' log.file >tmp.txt log file time format is 2016-09-27 14:00:25,192 Use code... (1 Reply)
Discussion started by: Prashanth.K
1 Replies

3. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

4. UNIX for Advanced & Expert Users

Script to read log file

Hi, Im looking for a shell script which will search for a particular string in a log file as below scenario 1. I need to run URL http://localhost/client/update?feedid=200 in shell script at(eg)4:00 PM which will not take more than 15 mins to complete. 2. After 15 mins i need to... (6 Replies)
Discussion started by: Paulwintech
6 Replies

5. Shell Programming and Scripting

shell script to grep 500 error messages from access logs

Hello Team, I need help to improve my script which is used to grep 500 error messages in the logs. I am using following logic in the script to grep 500 error messages in the logs. var1=`awk '$9 == "500"' access_log | tail -1` The above logic is not useful if logs are not getting... (1 Reply)
Discussion started by: coolguyamy
1 Replies

6. Shell Programming and Scripting

Unix script help to read log file

Hi I have a big log file :08,936 DEBUG HttpConnectionManager.getConnection: config = 11:39:08,936 DEBUG Getting free connection, 11:39:08,989 DEBUG Freeing connection, hostConfig=HostConfiguration 11:39:08,989 DEBUG Notifying no-one, there are no waiting threads 11:39:09,046... (4 Replies)
Discussion started by: javaholics
4 Replies

7. Shell Programming and Scripting

Help w/ script to read file and parse log message

Hi, I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***... The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE. Can anyone give help? Thanks (2 Replies)
Discussion started by: shyork2001
2 Replies

8. Shell Programming and Scripting

help using read in menu script to cat out lines in logs

What is wrong with my menu script? Do I need to continue with the read statements? All I want to do with option 4 is to cat some /var/log/files and awk out a few lines? How do I do that please? $ cat menu.sh ... (11 Replies)
Discussion started by: taekwondo
11 Replies

9. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

10. UNIX for Dummies Questions & Answers

Constantly updating log files (tail -f? grep? awk?)

I have a log file which is continuously added to, called log.file. I'd like to monitor this file, and when certain lines are found, update some totals in another file. I've played around with tail -f, grep, and awk, but can't seem to hit the right note, so to speak. The lines I'm... (0 Replies)
Discussion started by: nortonloaf
0 Replies
Login or Register to Ask a Question