Sponsored Content
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 Post 302539029 by pravin27 on Friday 15th of July 2011 02:41:10 AM
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

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
strerr(1M)						  System Administration Commands						strerr(1M)

NAME
strerr - STREAMS error logger daemon SYNOPSIS
strerr DESCRIPTION
strerr receives error log messages from the STREAMS log driver (see log(7D)) and appends them to a log file. The resultant error log files reside in the directory /var/adm/streams, and are named error.mm-dd, where mm is the month and dd is the day of the messages contained in each log file. The format of an error log message is: <seq> <time> <ticks> <flags> <mid> <sid> <text> <seq> error sequence number <time> time of message in hh:mm:ss <ticks> time of message in machine ticks since boot priority level <flags> T : the message was also sent to a tracing process F : indicates a fatal error N : send mail to the system administrator (hardcoded as root) <mid> module ID number of source <sid> sub-ID number of source <text> formatted text of the error message Messages that appear in the error log are intended to report exceptional conditions that require the attention of the system administrator. Those messages which indicate the total failure of a STREAMS driver or module should have the F flag set. Those messages requiring the immediate attention of the administrator will have the N flag set, which causes the error logger to send the message to the system adminis- trator using mail. The priority level usually has no meaning in the error log but will have meaning if the message is also sent to a tracer process. Once initiated, strerr continues to execute until terminated by the user. It is commonly executed asynchronously. FILES
/var/adm/streams/error.mm-dd error log file. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5), log(7D) STREAMS Programming Guide NOTES
There is no restriction to the number of strerr processes opening the STREAMS log driver at a time. If a module or driver is generating a large number of error messages, running the error logger will cause a degradation in STREAMS perfor- mance. If a large burst of messages are generated in a short time, the log driver may not be able to deliver some of the messages. This situation is indicated by gaps in the sequence numbering of the messages in the log files. SunOS 5.10 4 Oct 1994 strerr(1M)
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy