How can view log messages between two time frame from /var/log/message or any type of log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can view log messages between two time frame from /var/log/message or any type of log files
# 1  
Old 07-14-2011
How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files.

when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval.

Could you pls give me the command?
# 2  
Old 07-15-2011
Try this,
Code:
#!/bin/sh
date1='Jul 15 2011 07:21:28'

date1_sec=$(date -d "$date1" '+%s')
date2_sec=$(date -d "$date1  5 min ago" '+%s')
while read line
do
        line_date=$(echo $line | awk '{print $1,$2,$3}')
        sec=$(date -d "$line_date" '+%s')
        if [ $date2_sec -le $sec -a $date1_sec -ge $sec ]
        then
                echo $line
        fi
done < /var/log/messages

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transfer the logs being thrown into /var/log/messages into another file example /var/log/volumelog

I have been searching and reading about syslog. I would like to know how to Transfer the logs being thrown into /var/log/messages into another file example /var/log/volumelog. tail -f /var/log/messages dblogger: msg_to_dbrow: no logtype using missing dblogger: msg_to_dbrow_str: val ==... (2 Replies)
Discussion started by: kenshinhimura
2 Replies

2. Shell Programming and Scripting

Log all the commands input by user at real time in /var/log/messages

Below is my script to log all the command input by any user to /var/log/messages. But I cant achieve the desired output that i want. PLease see below. function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "$USER:$COMMAND" } trap... (12 Replies)
Discussion started by: invinzin21
12 Replies

3. Shell Programming and Scripting

Help on script to capture info on log file for a particular time frame

Hi I have a system running uname -a Linux cmovel-db01 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux I would like to capture the contents of /var/log/syslog from 11:00AM to 11:30AM and sent to this info via email. I was thinking in set a cron entry at that... (2 Replies)
Discussion started by: fretagi
2 Replies

4. Linux

Can we delete /var/log/messages-2015* files

Hi Team, My linux version is Linux 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux Now /var mount point is full, and I don't know what files to delete from this file system. When I checked /var/log there are lot of log files starting with name... (3 Replies)
Discussion started by: Bhavi
3 Replies

5. Solaris

Difference between /var/log/syslog and /var/adm/messages

Hi, Is the contents in /var/log/syslog and /var/adm/messages are same?? Regards (3 Replies)
Discussion started by: vks47
3 Replies

6. UNIX for Dummies Questions & Answers

Message in /var/log

What does this message mean: Dec 16 04:30:01 vader kernel: target2:0:4: FAST-10 SCSI 10.0 MB/s ST (100 ns, offset 8) (2 Replies)
Discussion started by: mojoman
2 Replies

7. UNIX for Dummies Questions & Answers

Message in /var/log/messages: Cannot do reverse lookup

Hi I have an entry in hosts.deny and now I get the following message in /var/log/messages: g 21 09:30:46 machine sshd: Failed password for illegal user d from ::ffff:213.229.69.42 port 57181 ssh2 Aug 21 09:30:46 machine sshd: Received disconnect from ::ffff:213.229.69.42: 11: Bye Bye Aug 21... (2 Replies)
Discussion started by: mojoman
2 Replies

8. Solaris

diff b/w /var/log/syslog and /var/adm/messages

hi sirs can u tell the difference between /var/log/syslogs and /var/adm/messages in my working place i am having two servers. in one servers messages file is empty and syslog file is going on increasing.. and in another servers message file is going on increasing but syslog file is... (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

9. UNIX for Dummies Questions & Answers

help interpreting var/log/messages log

I'm using RHEL and my var/log/messages file is filled with "FTP session opened/closed" lines that happen all day: Aug 2 04:04:38 web proftpd: 74.125.56.10 (142.231.76.249) - FTP session closed. Aug 2 04:05:11 web proftpd: 74.125.56.10 (142.231.88.123) - FTP session opened.Is this normal? We... (2 Replies)
Discussion started by: gaspol
2 Replies

10. Shell Programming and Scripting

Send-file /var/log/message

Hello All i need Shell Script to send /var/log/message or another if he have or grep this file to have some info like PID or value (e.g like NFS mount - stop ) to some body in my System Thanks for Advanced (2 Replies)
Discussion started by: Hosam
2 Replies
Login or Register to Ask a Question