Sponsored Content
Full Discussion: Grep last 2 minutes log only
Top Forums Shell Programming and Scripting Grep last 2 minutes log only Post 303019646 by ooilinlove on Tuesday 3rd of July 2018 09:17:39 AM
Old 07-03-2018
Grep last 2 minutes log only

I have newbie,
which i use for checking last one hours log file,
but i want to check 2 minutes log and discard old log, only match current time with last 2 minutes.


Ex log.
Code:
2018-07-03 20:09:17
2018-07-03 20:05:17
2018-07-03 20:05:18
2018-07-03 20:05:20
2018-07-03 20:06:22
2018-07-03 20:06:26
2018-07-03 20:07:26
2018-07-03 20:07:29
2018-07-03 20:07:30
2018-07-03 20:07:30
2018-07-03 20:07:31
2018-07-03 20:09:31
2018-07-03 20:09:32
2018-07-03 20:09:32
2018-07-03 20:09:33
2018-07-03 20:09:33
2018-07-03 20:09:34
2018-07-03 20:09:35
2018-07-03 20:09:36
2018-07-03 20:09:39
2018-07-03 20:09:41
2018-07-03 20:09:44
2018-07-03 20:09:45
2018-07-03 20:09:47
2018-07-03 20:09:48
2018-07-03 20:09:49
2018-07-03 20:09:49
2018-07-03 20:09:50
2018-07-03 20:09:50
2018-07-03 20:09:50
2018-07-03 20:09:51
2018-07-03 20:09:52
2018-07-03 20:09:52
2018-07-03 20:09:53
2018-07-03 20:09:53
2018-07-03 20:09:54
2018-07-03 20:09:54
2018-07-03 20:09:56
2018-07-03 20:10:00
2018-07-03 20:10:03
2018-07-03 20:10:04
2018-07-03 20:10:06
2018-07-03 20:10:08
2018-07-03 20:10:13
2018-07-03 20:10:13
2018-07-03 20:10:15
2018-07-03 20:10:15
2018-07-03 20:10:17
2018-07-03 20:10:21
2018-07-03 20:10:22
2018-07-03 20:10:22
2018-07-03 20:10:23
2018-07-03 20:10:23
2018-07-03 20:10:24
2018-07-03 20:10:24
2018-07-03 20:10:25
2018-07-03 20:10:25
2018-07-03 20:10:26
2018-07-03 20:10:26
2018-07-03 20:10:27
2018-07-03 20:10:28
2018-07-03 20:10:29
2018-07-03 20:10:29
2018-07-03 20:10:30
2018-07-03 20:10:31
2018-07-03 20:10:31
2018-07-03 20:10:32
2018-07-03 20:10:35
2018-07-03 20:10:39
2018-07-03 20:10:39
2018-07-03 20:10:39
2018-07-03 20:10:40
2018-07-03 20:10:41
2018-07-03 20:10:41
2018-07-03 20:10:43
2018-07-03 20:10:44
2018-07-03 20:10:46
2018-07-03 20:10:49
2018-07-03 20:10:50
2018-07-03 20:10:50
2018-07-03 20:10:53
2018-07-03 20:10:55
2018-07-03 20:10:56
2018-07-03 20:10:57
2018-07-03 20:10:57
2018-07-03 20:10:59
2018-07-03 20:10:59
2018-07-03 20:11:00
2018-07-03 20:11:00
2018-07-03 20:11:06
2018-07-03 20:11:08
2018-07-03 20:11:10
2018-07-03 20:11:11
2018-07-03 20:11:12
2018-07-03 20:11:14
2018-07-03 20:11:15
2018-07-03 20:11:35
2018-07-03 20:11:39
2018-07-03 20:11:58
2018-07-03 20:11:59

i want command to grep log only 2 min from last line.
example 2018-07-03 20:10:00 - 2018-07-03 20:11:59
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

2. Shell Programming and Scripting

Grepping the last 30 minutes of a log file...

I need to know if anyone can assist me on how to grab the last (we'll just say "x" minutes) of a log file. How do you tell the grep command without specifying an exact window of time? (So relative instead of absolute.) Thanks, Jon (2 Replies)
Discussion started by: jtelep
2 Replies

3. Shell Programming and Scripting

grep the time within given minutes

Mar 26 15:25:11 : jdoe : TTY=pts/2 ; PWD=/home/jdoe ; USER=root ; COMMAND=/usr/bin/su - Mar 26 15:28:52 : jdoe : 3 incorrect password attempts ; TTY=pts/2 ; PWD=/home/jdoe ; USER=root ; COMMAND=/usr/bin/su - Mar 25 12:23:07 : jdoe : TTY=pts/2 ; PWD=/home/jdoe ; USER=root ; ... (6 Replies)
Discussion started by: Daniel Gate
6 Replies

4. Shell Programming and Scripting

Script to grep for a string in log files generated in last 15 minutes.

Dear Guru's I've a requirment to grep for a string in series of log files that are getting generated almost every minute. I'm looking to schedule a script every 15 mountes,in order to check if the error string has been generated in any of the log files generated in last 15 minutes. Please... (3 Replies)
Discussion started by: rajivatnova
3 Replies

5. Shell Programming and Scripting

Move all .log except those generated in the last 5 minutes

RHEL 5.8 In the directory /u03/pkms/app_logs I have several hundreds of log files as shown below. $ pwd /u03/pkms/app_logs $ ls -alrt *.log | tail -50 -rw-r----- 1 oracle dba 9439232 May 4 13:57 mvtpcem_1_722892404_94157.log -rw-r----- 1 oracle dba 9227264 May 4 13:57... (8 Replies)
Discussion started by: kraljic
8 Replies

6. Shell Programming and Scripting

Log File Creations for every 60 minutes

Hi All, Below script will make a copy of the existing log file with the then timestamp details. I am looking to create a copy of the existing log file for every 60 minutes and when the file limit reaches to 5, the 6th copy should overwrite the first backedup file which means all the time it... (3 Replies)
Discussion started by: Upendra Bestha
3 Replies

7. Shell Programming and Scripting

Grep last 30 minutes log only

I have below command, which i use for checking last two hours log file, but i want to check 30 minutes log and discard old log, only match current time with last 30 minutes. Command i am using. This below attach log file format is for this week, but sometime it got change in time of log, so i need... (6 Replies)
Discussion started by: learnbash
6 Replies

8. Shell Programming and Scripting

Run this grep every 10 minutes and do something based on the output

OS : Red Hat Linux 6.4 Shell : Bash We have a file called status.txt which will have only 1 line. The content will be the string "Processing" for most of the day. # cat status.txt Processing #I want to write a shell script (notify.sh) which will be executing a grep every 10 minutes . ... (7 Replies)
Discussion started by: kraljic
7 Replies

9. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies

10. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099 module.py:700] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569 module.py:700] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies
tbl(1)								   User Commands							    tbl(1)

NAME
tbl - format tables for nroff or troff SYNOPSIS
tbl [-me] [-mm] [-ms] [filename]... DESCRIPTION
tbl is a preprocessor for formatting tables for nroff(1) or troff(1). The input filenames are copied to the standard output, except that lines between .TS and .TE command lines are assumed to describe tables and are reformatted. If no arguments are given, tbl reads the standard input, so tbl may be used as a filter. When tbl is used with eqn(1) or neqn, the tbl command should be first, to minimize the volume of data passed through pipes. OPTIONS
-me Copy the -me macro package to the front of the output file. -mm Copy the -mm macro package to the front of the output file. -ms Copy the -ms macro package to the front of the output file. EXAMPLES
Example 1 Using tbl As an example, letting `@' (at-sign) represent a TAB, which should be typed as an actual TAB character in the input file .TS c s s c c s c c c l n n. Household Population Town@Households @Number@Size Bedminster@789@3.26 Bernards Twp.@3087@3.74 Bernardsville@2018@3.30 Bound Brook@3425@3.04 Branchburg@1644@3.49 .TE yields Household Population Town Households Number Size Bedminster 789 3.26 Bernards Twp. 3087 3.74 Bernardsville 2018 3.30 Bound Brook 3425 3.04 Branchburg 1644 3.49 FILES
/usr/share/lib/tmac/e -me macros /usr/share/lib/tmac/m -mm macros /usr/share/lib/tmac/s -ms macros ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWdoc | +-----------------------------+-----------------------------+ SEE ALSO
eqn(1), nroff(1), troff(1), attributes(5) SunOS 5.11 2 Aug 1994 tbl(1)
All times are GMT -4. The time now is 04:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy