08-27-2009
Get all lines in a file after particular time
Hi All,
I am lookig for a way to get all the lines from a log file which has been updated 5 mins prior to the system time.
The log file will be like below:
09:01:00 Started polling
09:01:05 Checking directory test
09:02:00 Error! Cannot access directory test
09:03:00 Polling
I get the system time and calculate 5 mins before the system time. For example if the system time is 09:05, then the script will calculate the time to check as 09:00. Then a sed command will be run to get all the lines below the pattern:
sed '/$time/,$p' $logfile
Which will print all the lines below the pattern. But if the log file does not contain 09:00, no lines will be grepped. Is there a way to solve this issue?
Thanks
D
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello Friends,
I want to write a script for the following:
nlscux62:tibprod> grep "2008 Apr 30 01:" SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2.log | grep -i post | more
2008 Apr 30 01:01:23:928 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info AER3-000095 IDOC... (2 Replies)
Discussion started by: satyakam
2 Replies
2. Shell Programming and Scripting
hiii,
i have to write a shell script like this----
i have a huge log file name abc.log .i have to search for a pattern name "pattern",it may occur 1000 times in the log file,every time it finds the pattern it should display the 10 lines above the pattern.
I appericiate your help. (30 Replies)
Discussion started by: namishtiwari
30 Replies
3. Shell Programming and Scripting
Hi Experts,
I am writing a shell/Perl script tp get a time diffrence of two lines in a log file. I am pasting a snippet of my log file, how it look likes.
Sun Apr 26 02:11:03.162 2009 Greenwich Standard Time LOW: pid 488 tid 2072: 0: 251360: calling ARRF_LIB_Evaluate.
Sun Apr 26... (24 Replies)
Discussion started by: namishtiwari
24 Replies
4. Shell Programming and Scripting
Hi,
anyone has any ideas on how do we extract lines from a file with format similiar to this: (based on current time)
Jun 18 00:16:50 .......... ............. ............
Jun 18 00:17:59 .......... ............. ............
Jun 18 01:17:20 .......... ............. ............
Jun 18... (5 Replies)
Discussion started by: faelric
5 Replies
5. Shell Programming and Scripting
I have files that store multiple data points for the same device "vertically" and include multiple devices. It repeats a consistant pattern of lines where for each line:
Column 1 is a common number for the entire file and all devices in that file
Column 2 is a unique device number
Column 3 is... (7 Replies)
Discussion started by: STN
7 Replies
6. Shell Programming and Scripting
Dear All,
Please advice me, I have a text file with one field date and time like below given. I need to find out the lines whchi content the time stamp between
Wed May 26 11:03:11 2010 and Wed May 26 11:03:52 2010 both can be included, using awk command which could be an interactive so that I... (6 Replies)
Discussion started by: chinmayadalai
6 Replies
7. Shell Programming and Scripting
Hello
I have a file in following format:
IV 08:09:07
NM 08:12:01
IC 08:12:00
MN 08:14:20
NM 08:14:15
I need a script to compare time on each line with previous line and show the inconsecutive line. Ex.:
08:12:00
08:14:15
A better way... (6 Replies)
Discussion started by: vilibit
6 Replies
8. Shell Programming and Scripting
Hello community,
what I need to do is read 2 rows at time from a file. I have this simple solution:
File to read:
LINE1
LINE2
LINE3
LINE4
LINE5
LINE6
LINE7
LINE8Read routine:#!/bin/ksh
sed '1,3d' /out.txt | while read line; do
read line2
echo $line $line2
doneResult:LINE1... (5 Replies)
Discussion started by: Lord Spectre
5 Replies
9. Shell Programming and Scripting
Hello All,
I have a file like below....
dn: cn=user1,ou=org,o=org
cn=user1
uid=user1
cn=user2,ou=org,o=org
cn=user2
uid=user2
cn=user3,ou=org,o=org
cn=user3
cn=user33
uid=user3
cn=user4,ou=org,o=org
cn=user4
uid=user4 (6 Replies)
Discussion started by: s_linux
6 Replies
10. Shell Programming and Scripting
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)
Discussion started by: cele_82
1 Replies
uptime(1) User Commands uptime(1)
NAME
uptime - show how long the system has been up
SYNOPSIS
uptime
DESCRIPTION
The uptime command prints the current time, the length of time the system has been up, and the average number of jobs in the run queue over
the last 1, 5 and 15 minutes. It is, essentially, the first line of a w(1) command.
EXAMPLES
Below is an example of the output uptime provides:
example% uptime
10:47am up 27 day(s), 50 mins, 1 user, load average: 0.18, 0.26, 0.20
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
w(1), who(1), whodo(1M), attributes(5)
NOTES
who -b gives the time the system was last booted.
SunOS 5.10 18 Mar 1994 uptime(1)