Sponsored Content
Top Forums Shell Programming and Scripting Collecting all lines between two time stamp from the log Post 302960840 by RudiC on Friday 20th of November 2015 05:03:45 AM
Old 11-20-2015
awk equivalent:
Code:
awk '/150318 23:19:04/,/150318 23:55:04/' file
150318 23:19:04 logentries 
150318 23:29:04 logentries 
150318 23:39:04 logentries 
logentries 
logentries 
logentries 
150318 23:49:04 logentries 
150318 23:55:04 logentries

But all of these would work only if the exact time stamps are known and given. Should that not be the case, you'll need to read every line and interpret/calculate the time values before comparing to the lower and upper limits.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Inserting Date&Time Stamp In Existing Log File

I am trying to insert a line with a date stamp in a file that is used to monitor activity in one of our directories. By doing this, I want to grep that file each day and go to the last entry for each time a error occurred and pull all errors generated if any exist. If error exists I want that error... (3 Replies)
Discussion started by: shephardfamily
3 Replies

2. Shell Programming and Scripting

Extract info from log file and compute using time date stamp

Looking for a shell script or a simple perl script . I am new to scripting and not very good at it . I have 2 directories . One of them holds a text file with list of files in it and the second one is a daily log which shows the file completion time. I need to co-relate both and make a report. ... (0 Replies)
Discussion started by: breez_drew
0 Replies

3. Shell Programming and Scripting

Remove lines of the same time stamp leaving the highest

Hi guys, I have a log that looks like that below. Columns 2 3 4 5 6 7 is the date/time stamp separated by comma. UUU,02,06,2010,10,00,00,00,0000000000000000,0000000000000000,0000000000001224 UUU,02,06,2010,10,05,00,00,0000000000000000,0000000000000000,0000000000001502... (2 Replies)
Discussion started by: borderblaster
2 Replies

4. Shell Programming and Scripting

Identify log files based on time stamp,zip and then copy..HELP

Hi All, PFB is a requirement. I am new to shell scripting. So plz help. It would be highly appreciated. 1. choose all the log files based on a particular date (files location is '/test/domain')--i.e,we should choose all the files that are modified on 29th November, neither 28th nor 30th 2.... (3 Replies)
Discussion started by: skdas_niladri
3 Replies

5. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

6. Shell Programming and Scripting

awk : collecting all data between two time frame

Hi Experts , I need your help to collect the complete data between two time frame from the log files, when I try awk it's collecting the data only which is printed with time stamp for example, awk works well from "16:00 to 17:30" but its not collecting <line*> "from 17:30 to 18:00" ... (8 Replies)
Discussion started by: zenkarthi
8 Replies

7. Shell Programming and Scripting

To check time stamp in log file and calculate.

Hi Friends, I have the following logfile. i want to make a script for calculate time by time2 - time1 1600266278|random|1|2014-09-19 02:08:56.024|2014-09-19 02:08:59.398|A|B|ROOM|Num0208559970111101788|1|dog|dos 1600266200|random|4|2014-09-19 02:08:06.572|2014-09-19... (2 Replies)
Discussion started by: ooilinlove
2 Replies

8. Shell Programming and Scripting

Collecting logs between two time stamps

Hi, please help me to collect the entire log files between two time stamp. for example, I am looking script to collect the entire log between "2015-03-27 15:59" to "2015-03-27 16:15" in the below sample log file. OS : RHEL 6.3 Date/Time : 24 hours format, the time is printing each log... (12 Replies)
Discussion started by: jerryknj
12 Replies

9. Shell Programming and Scripting

Need Time Stamp Range On Log Files

I have created this script #!/bin/sh FILES=/data/log/access_*.log for f in $FILES do echo "Processing $f file" cat $f | awk '{print $1}' | sort | uniq -c | sort -n | tail done It produces this output Processing /data/log/access_abc.log file 114 1.1.1.1 167 2.2.2.2 ... (38 Replies)
Discussion started by: sharingsunshine
38 Replies

10. Shell Programming and Scripting

Shell Script | Parse log file after a given date and time stamp

I am developing one script which will take log file name, output file name, date, hour and minute as an argument and based on these inputs, the script will scan and capture all the error(s) that have been triggered from a given time. Example: script should capture all the error after 13:50 on Jan... (2 Replies)
Discussion started by: ROMA3
2 Replies
DBILogger(3pm)						User Contributed Perl Documentation					    DBILogger(3pm)

NAME
Apache::DBILogger - Tracks what's being transferred in a DBI database SYNOPSIS
# Place this in your Apache's httpd.conf file PerlLogHandler Apache::DBILogger PerlSetVar DBILogger_data_source DBI:mysql:httpdlog PerlSetVar DBILogger_username httpduser PerlSetVar DBILogger_password secret PerlSetvar DBILogger_table requests Create a database with a table named requests like this: CREATE TABLE requests ( server varchar(127) DEFAULT '' NOT NULL, bytes mediumint(9) DEFAULT '0' NOT NULL, user varchar(15) DEFAULT '' NOT NULL, filename varchar(200) DEFAULT '' NOT NULL, remotehost varchar(150) DEFAULT '' NOT NULL, remoteip varchar(15) DEFAULT '' NOT NULL, status smallint(6) DEFAULT '0' NOT NULL, timeserved datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, contenttype varchar(50) DEFAULT '' NOT NULL, urlpath varchar(200) DEFAULT '' NOT NULL, referer varchar(250) DEFAULT '' NOT NULL, useragent varchar(250) DEFAULT '' NOT NULL, usertrack varchar(100) DEFAULT '' NOT NULL, KEY server_idx (server), KEY timeserved_idx (timeserved) ); Please note that for some databases (notably, PostgreSQL) you will need to double-quote the user column name (that is, to specify it as ""user" varchar(15)") in order for the database not to mistake it with a keyword. Its recommended that you include use Apache::DBI; use DBI; use Apache::DBILogger; in your startup.pl script. Please read the Apache::DBI documentation for further information. DESCRIPTION
This module tracks what's being transfered by the Apache web server in a SQL database (everything with a DBI/DBD driver). This allows one to get statistics (of almost everything) without having to parse the log files (like the Apache::Traffic module, just in a "real" database, and with a lot more logged information). Apache::DBILogger will track the cookie from 'mod_usertrack' if it's there. After installation, follow the instructions in the synopsis and restart the server. The statistics are then available in the database. See the section VIEWING STATISTICS for more details. PREREQUISITES
You need to have compiled mod_perl with the LogHandler hook in order to use this module. Additionally, the following modules are required: o DBI o Date::Format INSTALLATION
To install this module, move into the directory where this file is located and type the following: perl Makefile.PL make make test make install This will install the module into the Perl library directory. Once installed, you will need to modify your web server's configuration file so it knows to use Apache::DBILogger during the logging phase. VIEWING STATISTICS
Please see the bin/ directory in the distribution for a statistics script. Some funny examples on what you can do might include: hit count and total bytes transfered from the virtual server www.company.com select count(id),sum(bytes) from requests where server="www.company.com" hit count and total bytes from all servers, ordered by number of hits select server,count(id) as hits,sum(bytes) from requests group by server order by hits desc count of hits from macintosh users select count(id) from requests where useragent like "%Mac%" hits and total bytes in the last 30 days select count(id),sum(bytes) from requests where server="www.company.com" and TO_DAYS(NOW()) - TO_DAYS(timeserved) <= 30 This is pretty unoptimal. It would be faster to calculate the dates in perl and write them in the sql query using f.x. Date::Format. hits and total bytes from www.company.com on mondays. select count(id),sum(bytes) from requests where server="www.company.com" and dayofweek(timeserved) = 2 It's often pretty interesting to view the referer info too. See your sql server documentation of more examples. I'm a happy mySQL user, so I would continue on http://www.tcx.se/Manual_chapter/manual_toc.html LOCKING ISSUES
MySQL 'read locks' the table when you do a select. On a big table (like a large httpdlog) this might take a while, where your httpds can't insert new logentries, which will make them 'hang' until the select is done. One way to work around this is to create another table (f.x. requests_insert) and get the httpd's to insert to this table. Then run a script from crontab once in a while which does something like this: LOCK TABLES requests WRITE, requests_insert WRITE insert into requests select * from requests_insert delete from requests_insert UNLOCK TABLES You can use the moverows.pl script from the bin/ directory. Please note that this won't work if you have any unique id field! You'll get duplicates and your new rows won't be inserted, just deleted. Be careful. TRAPS
I've experienced problems with 'Packets too large' when using Apache::DBI, mysql and DBD::mysql 2.00 (from the Msql-mysql 1.18x packages). The DBD::mysql module from Msql-mysql 1.19_17 seems to work fine with Apache::DBI. You might get problems with Apache 1.2.x. (Not supporting post_connection?) MOD_PERL 2 SUPPORT The official version of this module, as Ask Bjoern Hansen last modified it, lacks support for the API changes introduced with Apache 2.x and the corresponding mod_perl 2.x - Of course, this is quite understandable as this module was last updated in 1998 ;-) But anyway, the module does its job still quite fine, and users still require its functionality. For any help requests regarding this module on Apache 2 systems, contact Gunnar Wolf <gwolf@debian.org> directly. If your system is based on Debian GNU/Linux, you can use the regular Debian bugtracking facilities, as the multi-API patch was introduced specifically for Debian. SUPPORT
This module is supported via the mod_perl mailinglist (modperl@apache.org, subscribe by sending a mail to modperl-request@apache.org). I would like to know which databases this module have been tested on, so please mail me if you try it. The latest version can be found on your local CPAN mirror or at "ftp://ftp.netcetera.dk/pub/perl/" AUTHOR
Copyright (C) 1998, Ask Bjoern Hansen <ask@netcetera.dk>. All rights reserved. This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl(1), mod_perl(3) perl v5.12.3 2011-06-16 DBILogger(3pm)
All times are GMT -4. The time now is 09:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy