Sponsored Content
Top Forums Shell Programming and Scripting Need help in getting the Last 30 minutes logs from the Log File Post 302953850 by RudiC on Wednesday 2nd of September 2015 04:24:07 AM
Old 09-02-2015
Quoting is the crucial part in parameter passing into your awk script. Try:
Code:
awk -F - -vDT="$(date --date="600 minutes ago" "+%b %_d %H:%M:%S")" ' DT < $1' log_file_updated.txt
Sep  2 02:45:48 adcsdb1 UDSAgent[44247]: 2015-07-05 04:24:48.959 INFO   Worker_Thread_4032813936 Accepted connection from host <unknown> (ipaddress 10.80.116.60:40819)
Sep  2 02:51:49 adcsdb1 multipathd: dm-12: devmap not registered, can't remove

Your second date reference yields the system time, and presuming no log entry is done for the future I neglected that test.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

get last 5 minutes' log from log file?

Hi all, I have tried to figure out a way to automatically get the last 5 minutes' log content from log file, at first, my thoughts like this, sed -n "/ $(date +\%R -d "-5 min")/,$"p syslog > newfile, but quickly I found it did not work, say I have a syslog file as following, Jul 19... (5 Replies)
Discussion started by: fedora
5 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

Finding errors in log file only in last 10 minutes

Hi there, I have a log file that I need to check every 10 minutes to find if a specific error exists but only in that 10 minute period. The reason is that the log is quite large, and will frequently contain these errors, so I only want alerting if it in the last 10 minutes - I don't want... (3 Replies)
Discussion started by: paul_vf
3 Replies

4. 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

5. Shell Programming and Scripting

Script to search for a pattern in 30 minutes from a log file

Hello All, I have to write a script which will search for diffrent patterns like "Struck" "Out of Memory" , etc from a log file in Linux box's. Now I will be executing a cron job to find out the results by executing the script once in every 30 minutes. suppose time is 14-04-29:05:31:09 So I... (3 Replies)
Discussion started by: Shubhasis Mathr
3 Replies

6. Shell Programming and Scripting

How to extract logs between the current time and the last 15 minutes ?

I want to extract the logs between the current time stamp and 15 minutes before and sent an email to the people configured. I developed the below script but it's not working properly; can someone help me?? I have a log file containing this pattern: Constructor QuartzJob ... (3 Replies)
Discussion started by: puneetkhullar
3 Replies

7. UNIX for Beginners Questions & Answers

Searching exception keyword in all logs in last 5 minutes

Hello Folks , I am a new bie to the world of unix , what i am planning to do is the I have the location in server to which i am access through the putty and the location is /mt/ttlog/avccomn/logs/201901/19 and at this location the files are listed as show startjmsnode1.sh_03.out... (7 Replies)
Discussion started by: punpun26262626
7 Replies

8. 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

9. Shell Programming and Scripting

Check file creation Time minutes and if file older then 5 minutes execute some stuff

Hello all, Info: System RedHat 7.5 I need to create a script that based on the creation time, if the file is older then 5 minutes then execute some stuff, if not exit. I thought to get the creation time and minutes like this. CreationTime=$(stat -c %y /tmp/test.log | awk -F" " '{ print... (3 Replies)
Discussion started by: charli1
3 Replies

10. UNIX for Beginners Questions & Answers

Copy last 30 minutes' contents from a log file

Hi Guys, I am writing a bash script to capture the last 30 minutes's contents from log file to a new file. This job is a scheduled job and will run every 30 minutes. The log file is db2diag.log in DB2. I am having difficulties copying the last 30 minutes's contents. Can someone please help me.... (4 Replies)
Discussion started by: naveed
4 Replies
Agent::Channel(3pm)					User Contributed Perl Documentation				       Agent::Channel(3pm)

NAME
Log::Agent::Channel - ancestor class for all Log::Agent channels SYNOPSIS
@Log::Agent::Channel::XXX::ISA = qw(Log::Agent::Channel); DESCRIPTION
The "Log::Agent::Channel" class is the root class from which all "Log::Agent" channels inherit. It is a deferred class, meaning that it cannot be instantiated directly. All the deferred routines need to be implemented by its heirs to form a valid driver. Internally, the various "Log::Agent::Driver" objects create "Log::Agent::Channel" instances for each logging channel defined at driver creation time. The channels are therefore architecturally hidden within "Log::Agent", since this module only provides redefined mappings for the various logxxx() routines (logerr(), logwarn(), logdie(), etc...). However, this does not mean that channel classes cannot be used externally: the "Log::Agent::Logger" extension makes "Log::Agent::Channel" objects architecturally visible, thereby offering an application-level logging API that can be redirected to various places transparently for the application. CHANNEL LIST
The following channels are currently made available by "Log::Agent". More channels can be defined by the "Log::Agent::Logger" extension: Log::Agent::Channel::File This channel writes logs to files, defined by their path or via a magical opening sequence such as "|cmd". See Log::Agent::Channel::File. Log::Agent::Channel::Handle This channel writes logs to an already opened descriptor, as specified by its file handle: an IO::Handle object, or a GLOB reference such as *FILE. See Log::Agent::Channel::Handle. Log::Agent::Channel::Syslog This channel redirects logs to the syslogd(8) daemon, which will then handle the dispatching to various logfiles, based on its own configuration. See Log::Agent::Channel::Syslog. INTERFACE
You need not read this section if you're only using "Log::Agent". However, if you wish to implement another channel, then this section might be of interest. The following routines are deferred and therefore need to be defined by the heir: write($priority, $logstring) Emit the log entry held in $logstring, at priority $priority. A trailing " " is added to the $logstring, if needed (i.e. if the physical entity does not do it already, like syslog does). The $priority argument must be a valid syslog priority, i.e. one of the following strings: "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug". The $logstring may not really be a plain string. It can actually be a Log::Agent::Message object with an overloaded stringification routine, so the illusion should be complete. close Close the channel. make This is the creation routine. Its signature varies for each channel, naturally. AUTHOR
Raphael Manfredi <Raphael_Manfredi@pobox.com> SEE ALSO
Log::Agent::Channel::File(3), Log::Agent::Channel::Handle(3), Log::Agent::Channel::Syslog(3), Log::Agent::Logger(3). perl v5.10.0 2002-03-09 Agent::Channel(3pm)
All times are GMT -4. The time now is 01:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy