08-29-2011
Grep the Content of a LOG File which has latest Date and Time
Hi All,
Need a small help. I have a log file which keeps updating for every Minute with multiple number of lines. I just want to grep few properties which has latest Date and Time to it. How do i do it?
I wanted to grep a property by name "Reloading cache with a maximum of" from the "123.log" which has some thousands of lines in it
When i use the command "cat 123.log | grep 'Reloading cache with a maximum of' " it fetches the data something like this
"2011-08-29/08:07:44.219 INFO EJB-Timer-0a6c6b1d-563b-4c3a-a756-c854ab44364e[target=jboss.j2ee:ear=ear-xxxx-xxx-xxxxx.ear,jar=xxx-xxxxx-xxx-253134.jar,name= / Reloading cache with a maximum of 10000 loads
2011-08-29/08:08:44.230 INFO EJB-Timer-0a6c6b1d-563b-4c3a-a756-c854ab44364e[target=jboss.j2ee:ear=ear-xxxx-xxx-xxxxx.ear,jar=xxx-xxxxx-xxx-253134.jar,name= / Reloading cache with a maximum of 10000 loads
2011-08-29/08:09:44.242 INFO EJB-Timer-0a6c6b1d-563b-4c3a-a756-c854ab44364e[target=jboss.j2ee:ear=ear-xxxx-xxx-xxxxx.ear,jar=xxx-xxxxx-xxx-253134.jar,name= / Reloading cache with a maximum of 10000 loads "
I always wanted my script to get the last row which has latest date and time in it.
Can someone please HELP its urgent..........
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I wrote a small perl script in unix that searches in a file and saves some information in a separate file. Since this is a log file, I would like to have the date added to file name. I have no idea where to start.
output:
log_010907.txt
thanks
ken (8 Replies)
Discussion started by: captoro
8 Replies
2. Shell Programming and Scripting
Hi,
I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work
I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies
3. Shell Programming and Scripting
Hi everyone,
Please help:)
I have a list of 1000 different files which comes daily to the directory.Some of
the files are not coming to the directory now.
I need to write a shell script to find the latest date and time of the files they
came to the directory. The files should be unique.... (1 Reply)
Discussion started by: karthicss
1 Replies
4. Shell Programming and Scripting
I've seen several examples of grep showing the filename the string was found in, but what I really need is grep to show the file details in long format (like ls -l would).
scenario is:
grep mobile_number todays_files
This will show me the string I'm after & which files they turn up in, but... (2 Replies)
Discussion started by: woodstock
2 Replies
5. Shell Programming and Scripting
hi all,
not sure if this has been posted b4 but i try to search but not valid.
this is my question:
when i do a ls -ltr there will be a list generated as follows:
-rw-r--r-- 1 root sys 923260 Jan 10 04:38 FilePolling.41025.083TL021.xml
-rw-r--r-- 1 root sys 1761337 Jan 10 04:40... (12 Replies)
Discussion started by: lweegp
12 Replies
6. Shell Programming and Scripting
To delete log files content older than 30 days and append the lastest date log file date in the respective logs
I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs
This is my script
cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies
7. Shell Programming and Scripting
Hi Experts ,
we have a CDC file where we need to get the latest record of the Key columns
Key Columns will be CDC_FLAG and SRC_PMTN_I
and fetch the latest record from the CDC_PRCS_TS
Can we do it with a single awk command.
Please help.... (3 Replies)
Discussion started by: vijaykodukula
3 Replies
8. Shell Programming and Scripting
hi,
i have a Archive directory in which files are archived or stored with date and time stamp to prevent over writing.
example:
there are 5 files
s1.txt
s2.txt
s3.txt
s4.txt
s5.txt
while moving these files to archive directory, date and time stamp is added.
of format `date... (9 Replies)
Discussion started by: Little
9 Replies
9. UNIX for Dummies Questions & Answers
I've got a job that finds and removes trace files based upon an access time of more than seven days (I've also tried a modify date).
find TABC* -atime +7 -exec rm +
find TABC* -mtime +7 -exec rm +
Whether I use -atime or -mtime, the process seems to work sporadically. Sometimes it removes... (6 Replies)
Discussion started by: Scottie1954
6 Replies
10. Shell Programming and Scripting
Hi All,
Please help.
I have requirement to read the file / folder based on the latest date and download the file and folder.
There will be files and folders in the location like
20140630-144422
20140630-144422.csv
20140707-182653
20140707-182653.csv
20140710-183153... (7 Replies)
Discussion started by: Praveen Pandit
7 Replies
LEARN ABOUT DEBIAN
test::mocktime::datecalc
Test::MockTime::DateCalc(3pm) User Contributed Perl Documentation Test::MockTime::DateCalc(3pm)
NAME
Test::MockTime::DateCalc -- fake time for Date::Calc functions
SYNOPSIS
use Test::MockTime;
use Test::MockTime::DateCalc; # before Date::Calc loads
# ...
use My::Module::Using::Date::Calc;
DESCRIPTION
"Test::MockTime::DateCalc" arranges for the functions in "Date::Calc" to follow the Perl level "time" function (see perlfunc), and in
particular any fake date/time set there by "Test::MockTime". The following "Date::Calc" functions are changed
System_Clock
Today
Now
Today_and_Now
This_Year
Gmtime
Localtime
Timezone
Time_to_Date
"Gmtime", "Localtime", "Timezone" and "Time_to_Date" are made to default to the Perl-level current "time". When called with an explicit
time argument they're unchanged.
Module Load Order
"Test::MockTime" or similar fakery must be loaded first, before anything with a "time()" call, which includes "Test::MockTime::DateCalc".
This is the same as all "CORE::GLOBAL" overrides, see "OVERRIDING CORE FUNCTIONS" in CORE.
"Test::MockTime::DateCalc" must be loaded before "Date::Calc". If "Date::Calc" is already loaded then its functions might have been
imported into other modules and such imports are not affected by the redefinitions made. For that reason "Test::MockTime::DateCalc"
demands it be the one to load "Date::Calc" for the first time. Usually this simply means having "Test::MockTime::DateCalc" at the start of
a test script, before the things you're going to test.
use strict;
use warnings;
use Test::MockTime ':all';
use Test::MockTime::DateCalc;
use My::Foo::Bar;
set_fixed_time('1981-01-01T00:00:00Z');
is (My::Foo::Bar::something(), 1981);
restore_time();
In a test script it's often good to have your own modules early to check they correctly load their pre-requisites. You might want a
separate test script for that so you don't accidentally rely on "Test::MockTime::DateCalc" loading "Date::Calc" for you.
Other Faking Modules
"Test::MockTime::DateCalc" can be used with other modules which mangle the Perl-level "time" too. For example "Time::Fake",
use Time::Fake; # fakery first
use Test::MockTime::DateCalc;
Or "Time::Mock",
use Time::Mock; # fakery first
use Test::MockTime::DateCalc;
"Time::Warp" (as of version 0.5) only exports a new "time", it's not a core override and so can't be used with "Test::MockTime::DateCalc".
SEE ALSO
Date::Calc, Test::MockTime, Time::Fake, Time::Mock
faketime(1)
HOME PAGE
http://user42.tuxfamily.org/test-mocktime-datecalc/index.html
COPYRIGHT
Copyright 2009, 2010 Kevin Ryde
Test-MockTime-DateCalc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at your option) any later version.
Test-MockTime-DateCalc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Test-MockTime-DateCalc. If not, see
<http://www.gnu.org/licenses/>.
perl v5.10.1 2010-09-15 Test::MockTime::DateCalc(3pm)