Grep lines between last hour timestamp and current timestamp
So basically I have a log file and each line in this log file starts with a timestamp:
I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings.
The issue I'm having, is with timestamp conversion and how to grep last hour timestamp in that format.
Using: Solaris 11
Thanks
Last edited by rbatte1; 09-15-2017 at 10:16 AM..
Reason: Added CODE tags to make it more readable
I want to read a log file from a particular location.In the logfile , lines contains timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file format.Please... (1 Reply)
I want to read a log file from a particular location.In the log file each line starts with timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file... (1 Reply)
Hello,
I've created the script below to compare the content of two files with a delay of an hour. After an hour, the lines that exist in both files, will be printed and executed.
The script now uses a counter to countdown 50 minutes. But what I would prefer is to check the file timestamp of... (3 Replies)
Normally we can use %s to find out the time in second since 1970.
But in my ksh, this format option is not available.
Example- date +%s
1268103151
above script command won't work in ksh. Can you guys provide its equivalent ? (3 Replies)
Hello to all.
I work at AIX system without perl installed and I am restricted user, so I am limited to bash. In script that I am writing, I have to read line from file and transform date that I found inside to Unix timestamp. Line in file look something like this:
Tue Mar 29 06:59:00... (5 Replies)
I am doing this in my script ..
currenttimestamp=`db2 "select current timestamp from SYSIBM.SYSDUMMY1 with ur"`
echo s $currenttimestamp
but this is how its shows
s 1 -------------------------- 2011-04-18-12.43.25.345071 1 record(s) selected.
How can I just get the timestamp... (6 Replies)
Hi All,
I am new to unix programming. I am trying for a requirement and the requirement goes like this.....
I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Hi Friends,
I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only
I can get the... (12 Replies)
I have a file like this
-rwxr-xr-x 1 rewq other 168 Jan 13 07:05 check_files.sh
I want to compare (check_files.sh time) with the current time to see if its is older than 2 hours or not
if it is not older than 2 hrs then do something.can someone help me on this?.I dont... (7 Replies)
Hello ,
I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by
EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt
Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies
LEARN ABOUT PHP
idate
IDATE(3) 1 IDATE(3)idate - Format a local time/date as integer
SYNOPSIS
int idate (string $format, [int $timestamp = time()])
DESCRIPTION
Returns a number formatted according to the given format string using the given integer $timestamp or the current local time if no time-
stamp is given. In other words, $timestamp is optional and defaults to the value of time(3).
Unlike the function date(3), idate(3) accepts just one char in the $format parameter.
PARAMETERS
o $format
-
The following characters are recognized in the $format parameter string
+------------------+---------------------------------------------------+
|$format character | |
| | |
| | Description |
| | |
+------------------+---------------------------------------------------+
| | |
| B | |
| | |
| | Swatch Beat/Internet Time |
| | |
| | |
| d | |
| | |
| | Day of the month |
| | |
| | |
| h | |
| | |
| | Hour (12 hour format) |
| | |
| | |
| H | |
| | |
| | Hour (24 hour format) |
| | |
| | |
| i | |
| | |
| | Minutes |
| | |
| | |
| I (uppercase i) | |
| | |
| | returns 1 if DST is activated, 0 otherwise |
| | |
| | |
| L (uppercase l) | |
| | |
| | returns 1 for leap year, 0 otherwise |
| | |
| | |
| m | |
| | |
| | Month number |
| | |
| | |
| s | |
| | |
| | Seconds |
| | |
| | |
| t | |
| | |
| | Days in current month |
| | |
| | |
| U | |
| | |
| | Seconds since the Unix Epoch - January 1 1970 |
| | 00:00:00 UTC - this is the same as time(3) |
| | |
| | |
| w | |
| | |
| | Day of the week ( 0 on Sunday) |
| | |
| | |
| W | |
| | |
| | ISO-8601 week number of year, weeks starting on |
| | Monday |
| | |
| | |
| y | |
| | |
| | Year (1 or 2 digits - check note below) |
| | |
| | |
| Y | |
| | |
| | Year (4 digits) |
| | |
| | |
| z | |
| | |
| | Day of the year |
| | |
| | |
| Z | |
| | |
| | Timezone offset in seconds |
| | |
+------------------+---------------------------------------------------+
o $timestamp
- The optional $timestamp parameter is an integer Unix timestamp that defaults to the current local time if a $timestamp is not
given. In other words, it defaults to the value of time(3).
RETURN VALUES
Returns an integer.
As idate(3) always returns an integer and as they can't start with a "0", idate(3) may return fewer digits than you would expect. See the
example below.
ERRORS /EXCEPTIONS
Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using
the system settings or the $TZ environment variable. See also date_default_timezone_set(3)CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.1.0 | |
| | |
| | Now issues the E_STRICT and E_NOTICE time zone |
| | errors. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
idate(3) example
<?php
$timestamp = strtotime('1st January 2004'); //1072915200
// this prints the year in a two digit format
// however, as this would start with a "0", it
// only prints "4"
echo idate('y', $timestamp);
?>
SEE ALSO date(3), getdate(3), time(3).
PHP Documentation Group IDATE(3)