Sponsored Content
Top Forums Shell Programming and Scripting Identifying files with a timestamp greater than a given timestamp Post 302621531 by nkm0brm on Tuesday 10th of April 2012 02:51:13 PM
Old 04-10-2012
Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp.

I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps greater than the given timestamp, but had the same "seconds" as the given timestamp.

Code:
#!/bin/ksh
 
DT_TMSTMP='2012-04-10 08:39:17.807192000'
 
touch --date "$DT_TMSTMP" ./last_date
for i in `find $INFA_SHARED/SrcFiles/NANTEST/Src -newer ./last_date`
do
  print $i
done
exit

It missed these three timestamps:
Code:
08:39:17.861192000
08:39:17.943182000
08:39:17.967204000

and picked up files starting at:
Code:
08:39:18.019186000

Do I have any options to fix this?
Thanks

Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 04-10-2012 at 04:34 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing timestamp of two files

Hi! I need to copy a whole bunch of file from a build directory to my working directory. Many of these files already exist in my working directory. I need to copy only those files that have been modified since I last copied.. How do I compare the timestamp of two files, so that I would copy... (2 Replies)
Discussion started by: jyotipg
2 Replies

2. Shell Programming and Scripting

conversion of different timestamp to standard timestamp

hi i need a scrit to convert one date format to another. for example i have three columns in a file which gets a different format, but lastly i want output with stadard timestamp as "yyyy-mm-dd hh:mm:ss" column1 column2 ... (2 Replies)
Discussion started by: dprakash
2 Replies

3. Shell Programming and Scripting

Timestamp of old files

Hi I have a question if i give ls -ltr i get in the following order I dont get time stamp of old files where as the latest ones have time stamp How can i get the timestamp in the old files of 2008 and the one file of Jan 2009 -rw-rw-r-- 1 console staff 204 Nov 19 2008 msg -rw-rw-r-- 1... (3 Replies)
Discussion started by: ssuresh1999
3 Replies

4. Shell Programming and Scripting

Getting a relative timestamp from timestamp stored in a file

Hi, I've a file in the following format 1999-APR-8 17:31:06 1500 3 45 1999-APR-8 17:31:15 1500 3 45 1999-APR-8 17:31:25 1500 3 45 1999-APR-8 17:31:30 1500 3 45 1999-APR-8 17:31:55 1500 3 45 1999-APR-8 17:32:06 1500 3 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

5. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

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)
Discussion started by: mailsara
2 Replies

6. Shell Programming and Scripting

Need to get all the records from a log file greater than timestamp supplied.

I have a log file which has records with hung thread information/error I need to find out hung thread from log file greater than timestamp supplied. 00000026 ThreadMonitor W WSVR0605W: Thread "WebContainer : 1" (00000027) has been active for 701879 milliseconds and may be hung. There is/are... (6 Replies)
Discussion started by: megh
6 Replies

7. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

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)
Discussion started by: srkmish
12 Replies

8. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

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

9. Shell Programming and Scripting

Listing of files between two timestamp

Hi, I want to list down the files between two timestamp. But I can not use newer or newermt command as it doesn't support these tokens. Is there any other way to achieve this? Else I have to write too much of coding . Input Dec 01 02:02 Dec 02 05:07 (8 Replies)
Discussion started by: Abhijit Sen
8 Replies

10. Shell Programming and Scripting

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: MON DD HH:MM:SS SEP 15 07:30:01 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. ... (1 Reply)
Discussion started by: nms
1 Replies
tcpslice(8)						      System Manager's Manual						       tcpslice(8)

NAME
tcpslice - Extracts sections of or merges tcpdump files SYNOPSIS
/usr/sbin/tcpslice [-dRrt] [-w file] [start-time [end-time]] file... OPTIONS
Dumps the start and end times specified by the given range and exits. This option is useful for checking that the given range actually specifies the times you think it does. If the -R, -r, or -t option has been specified, the times are dumped in the corresponding format; otherwise, raw format (-R) is used. Dumps the timestamps of the first and last packets in each input file as raw timestamps in the form sssssssss.uuuuuu. This option can not be specified in conjunction with the -r or -t option. Same as the -R option except the timestamps are dumped in human-readable format, similar to that used by the date(1) command. This option cannot be specified in conjunction with the -R or -t options. Same as the -R option except the timestamps are dumped in tcpslice format, in the ymdhmsu format. See the DESCRIPTION section. This option cannot be specified in conjunction with the -R or -r option. Directs the output to file rather than stdout. DESCRIPTION
The tcpslice program extracts portions of packet-trace files generated using the tcpdump -w command. It can also be used to concatenate files. The tcpslice command copies to stdout all packets from its input file(s) whose timestamps fall within a given range. The starting and end- ing times of the range may be specified on the command line. All ranges are inclusive. The starting time defaults to the time of the first packet in the first input file; this is called the first time. The ending time defaults to ten years after the starting time. Thus, the command tcpslice trace-file copies trace-file to stdout (assuming the file does not include more than ten years' worth of data). There are a number of ways to specify times. The first is using UNIX timestamps of the form sssssssss.uuuuuu (the format specified by the tcpdump -tt command). For example, 654321098.7654 specifies 38 seconds and 765,400 microseconds after 8:51PM PDT, Sept. 25, 1990. The examples in this reference page use Pacific Daylight Time (PDT); however, when displaying times and interpreting times symbolically (as shown in this reference page), tcpslice uses the local time zone, regardless of the time zone in which the tcpdump file was generated. The daylight saving setting used is that which is appropriate for the local time zone at the date in question. For example, times associated with summer months will usually include daylight saving effects, and those with winter months will not. Times may also be specified relative to either the first time (when specifying a starting time) or the starting time (when specifying an ending time) by preceding a numeric value in seconds with a plus sign (+). For example, a starting time of +200 indicates 200 seconds after the first time, and the two arguments +200 +300 indicate from 200 seconds after the first time through 500 seconds after the first time. Times may also be specified in terms of years (y), months (m), days (d), hours (h), minutes (m), seconds (s), and microseconds(u). For example, the UNIX timestamp 654321098.7654 discussed earlier could also be expressed as follows: 1990y9m25d20h51m38s765400u When specifying times using this style, fields that are omitted default as follows: If the omitted field is a unit greater than that of the first specified field, its value defaults to the corresponding value taken from either first time (if the starting time is being specified) or the starting time (if the ending time is being specified). If the omitted field is a unit less than that of the first specified field, then it defaults to zero. For example, suppose the input file has a first time of the UNIX timestamp mentioned previously (38 seconds and 765,400 microseconds after 8:51 PM PDT, September 25, 1990). The following example specifies 9:36 PM PDT on the same date: 21h36m The following example specifies a range from 9:36 PM PDT through 1:54 AM PDT the next day: 21h36m 26d1h54m Relative times can also be specified when using the ymdhmsu format. Omitted fields then default to zero (0) if the unit of the field is greater than that of the first specified field, and to the corresponding value taken from either the first time or the starting time if the omitted field's unit is less than that of the first specified field. Using the first time of the UNIX timestamp mentioned previously, the following example specifies a range from 10:00 PM PDT on that date through 11:10PM PDT: 22h +1h10m The following example specifies a range from 38.7654 seconds after 9:51 PM PDT through 38.7654 seconds after 11:01 PM PDT: +1h +1h10m The first hour of the file could be extracted using the following specification: +0 +1h Note that with the ymdhmsu format there is an ambiguity between using m for month or for minute. The ambiguity is resolved as follows: if an m field is followed by a d field, it specifies months; otherwise it specifies minutes. If more than one input file is specified, tcpslice first copies packets lying in the given range from the first file. It then increases the starting time of the range to lie just beyond the timestamp of the last packet in the first file, repeats the process with the second file, and so on. In this manner, files with interleaved packets are not merged. For a given file, only packets that are newer than any in the preceding files will be considered. This mechanism avoids any possibility of a packet occurring more than once in the output. RESTRICTIONS
An input filename that beings with a digit or a plus sign (+) can be confused with a start and end time. Such filenames can be specified with a leading period and backslash (./); for example, specify the file 04Jul76.trace as The tcpslice program cannot read its input from stdin, since it uses random-access to read through its input files. The tcpslice program does not write to its output to a terminal (as indicated by isatty(3)). This prevents binary data from displaying on a user's terminal. You must either redirect stdout or specify an output file using the -w option. The tcpslice program does not work properly on tcpdump files spanning more than one year with files containing portions of packets whose original length was more than 65,535 bytes or with files containing fewer than three packets. If you use these files, the following error message is displayed: couldn't find final packet in file These problems are due to the interpolation scheme used by tcpslice to significantly increase its processing speed when dealing with large trace files. The tcpslice program can efficiently extract slices from the middle of trace files of any size, and can also work with trun- cated trace files (that is, the final packet in the file is only partially present, typically caused by tcpdump being killed). SEE ALSO
Commands: pfstat(1), pfconfig(8), tcpdump(8) Files: bpf(7), packetfilter(7) tcpslice(8)
All times are GMT -4. The time now is 07:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy