To check timestamp in logfile and display lines upto 3 hours before current timestamp
Hi Friends,
I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only
Code:
[7/30/14 4:59:30 Exception Found
[7/30/14 5:18:55 Result is OK
[7/30/14 8:45:22 Exception found
[7/30/14 9:22:26 Exception found
[7/31/14 11:55:66 Exception found
I can get the timestamp in logfile as
Code:
awk '/Exception/ {print $1,$2}' trial.txt | sed 's/^.//' which gives below results
7/30/14 4:59:30
7/30/14 8:45:22
7/30/14 9:22:26
7/31/14 11:55:66
And i can get current timestamp as
Code:
date +"%m/%d/%Y %T"
07/31/2014 12:33:34
So, how can i compare current timestamp with timestamp in log file and display 'Exception' entries until last 3 hours.
---------- Post updated at 02:40 AM ---------- Previous update was at 02:07 AM ----------
I am trying this command. But it is throwing exception saying syntax error. What am i doing wrong?
Code:
awk '/Exception/ if ($1,$2 > $(date +"%m/%d/%Y %T" -d "3 hour ago")) print $1,$2 ' trial.txt | sed 's/^.//'
Last edited by Don Cragun; 07-31-2014 at 05:45 AM..
Reason: Add missing CODE tags.
I'm trying to compare 2 dates between current time and the timestamp on a file.
The date format is mmdd
Both return Apr 1 but when using if statement
line 11: Apr 1: command not found error is returned
#!/bin/sh
log="DateLog"
Current_Date=`date +%b%e`
Filepmdate=`ls -l /file.txt |... (1 Reply)
Hello to all.
I work at AIX system without perl installed and I am restricted user, so I am limited to bash. In script that I am writing, I have to read line from file and transform date that I found inside to Unix timestamp. Line in file look something like this:
Tue Mar 29 06:59:00... (5 Replies)
I am doing this in my script ..
currenttimestamp=`db2 "select current timestamp from SYSIBM.SYSDUMMY1 with ur"`
echo s $currenttimestamp
but this is how its shows
s 1 -------------------------- 2011-04-18-12.43.25.345071 1 record(s) selected.
How can I just get the timestamp... (6 Replies)
Hi All,
I am new to unix programming. I am trying for a requirement and the requirement goes like this.....
I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Hi,
In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date×tamp. I have to figure out the the data is a date or time stamp or date×tamp.
If it is date then append "<space>00:00:00"... (1 Reply)
I was looking at this script which outputs the two lines which differs less than one sec.
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
use constant SEC_MILIC => 1000;
my $file='infile';
## Open for reading argument file.
open my $fh, "<", $file or die "Cannot... (1 Reply)
I have a file like this
-rwxr-xr-x 1 rewq other 168 Jan 13 07:05 check_files.sh
I want to compare (check_files.sh time) with the current time to see if its is older than 2 hours or not
if it is not older than 2 hrs then do something.can someone help me on this?.I dont... (7 Replies)
Hello ,
I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by
EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt
Contents of... (6 Replies)
Hi Gurus,
I have a software which logs event in the log file and it has become to big to search into it.
I want to display all the lines from the log files between
<Jul 21, 2016 3:30:37 PM BST> to <Jul 21, 2016 3:45:37 PM BST>
that is 15 min data .
Please help
Use code tags, thanks. (10 Replies)
So basically I have a log file and each line in this log file starts with a timestamp:
MON DD HH:MM:SS
SEP 15 07:30:01
I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
LEARN ABOUT CENTOS
perl::critic::exception::aggregateconfiguration
Perl::Critic::Exception::AggregateConfiguration(3) User Contributed Perl Documentation Perl::Critic::Exception::AggregateConfiguration(3)NAME
Perl::Critic::Exception::AggregateConfiguration - A collection of a set of problems found in the configuration and/or command-line options.
DESCRIPTION
A set of configuration settings can have multiple problems. This is an object for collecting all the problems found so that the user can
see them in one run.
INTERFACE SUPPORT
This is considered to be a public class. Any changes to its interface will go through a deprecation cycle.
METHODS
"add_exception( $exception )"
Accumulate the parameter with rest of the exceptions.
"add_exceptions_from( $aggregate )"
Accumulate the exceptions from another instance of this class.
"exceptions()"
Returns a reference to an array of the collected exceptions.
"add_exception_or_rethrow( $eval_error )"
If the parameter is an instance of Perl::Critic::Exception::Configuration or Perl::Critic::Exception::AggregateConfiguration, add it.
Otherwise, "die" with the parameter, if it is a reference, or "confess" with it. If the parameter is false, simply returns.
"has_exceptions()"
Answer whether any configuration problems have been found.
"full_message()"
Concatenate the exception messages. See "full_message" in Exception::Class.
AUTHOR
Elliot Shank <perl@galumph.com>
COPYRIGHT
Copyright (c) 2007-2011 Elliot Shank.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.16.3 2014-06-09 Perl::Critic::Exception::AggregateConfiguration(3)