how to find difference of 2 timestamps in secs?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to find difference of 2 timestamps in secs?
# 1  
Old 03-24-2008
how to find difference of 2 timestamps in secs?

I have a requirement to find the time difference in second between 2 given time stamps. An example scenario is shown below:

30 Oct 11:42:29:992 DEBUG org.apache.commons.digester.Digester - New match='form-validation/global/validator' (IID=, TID=)

30 Oct 11:42:29:993 DEBUG org.apache.commons.digester.Digester - Fire begin() for SetPropertiesRule[] (IID=, TID=)

30 Oct 11:42:29:994 DEBUG org.apache.commons.digester.Digester.sax - endElement(,validator,validator) (IID=, TID=)

30 Oct 11:42:29:994 DEBUG org.apache.commons.digester.Digester - bodyText='' (IID=, TID=)

30 Oct 11:42:29:995 DEBUG org.apache.commons.digester.Digester - Popping body text '' (IID=, TID=)

30 Oct 11:42:29:999 DEBUG org.apache.commons.digester.Digester - Fire end() for SetPropertiesRule[] (IID=, TID=)

30 Oct 11:42:29:999 DEBUG org.apache.commons.digester.Digester.sax - startElement(,validator,validator) (IID=, TID=)

30 Oct 11:42:30:000 DEBUG org.apache.commons.digester.Digester - Pushing body text '' (IID=, TID=)

30 Oct 11:42:30:000 DEBUG org.apache.commons.digester.Digester - Fire begin() for SetPropertiesRule[] (IID=, TID=)

30 Oct 11:42:30:001 DEBUG org.apache.commons.digester.Digester - match='form-validation/global/validator' (IID=, TID=)

30 Oct 11:42:30:001 DEBUG org.apache.commons.digester.Digester - bodyText='' (IID=, TID=)

30 Oct 11:42:30:001 DEBUG org.apache.commons.digester.Digester - Fire body() for SetPropertiesRule[] (IID=, TID=)


I want to get the time difference of the date field of the last line (30 Oct 11:42:30:001) and that of the first line (30 Oct 11:42:29:992) in seconds. That should work correctly across days and across years also. Can someone please help me solving this issue?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find file between timestamps Query

On my linux box, I have a file say dump.txt. I then need to move to another seperte folder and need to find only one file with extension *.tar that has the closest timestamp after / next to the timestamp of the dump.txt. (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Find matching timestamps in two files.

OK. if the first file is : 3184 2014-07-28 04:15 global.Remote-Access 10.111.8.25 81.245.6.25 tcp 3268 3035 2014-07-28 04:16 global.Remote-Access 10.111.8.12 81.245.6.25 tcp 3268If the second file is: 1 Jul 28 04:12 2014-07-28 id967254(BGC-TLW-Cert) Tunneling: User with IP... (8 Replies)
Discussion started by: fxsme
8 Replies

3. Shell Programming and Scripting

Finding difference in 2 different timestamps

Legends, I have a requirement to run the script exactly after one hour of completion of dependent script. Eg: Script B should run after one hour on the completion of Script A. I got the time stamps using following variables. these scripts runs in autosys > DATE=`date +%H:%M` >... (4 Replies)
Discussion started by: sdosanjh
4 Replies

4. Shell Programming and Scripting

Calculate difference in timestamps based on unique column value

Hi Friends, Require a quick help to write the difference between 2 timestamps based on a unique column value: Input file: 08/23/2012 12:36:09,JOB_5340,08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350,08/23/2012 12:36:26,JOB_5350 08/23/2012 13:08:51,JOB_5360,08/23/2012... (4 Replies)
Discussion started by: asnandhakumar
4 Replies

5. AIX

How to find time difference between 2 timestamps?

HI All, can some one please help me how to fine the difference between two time stamps say a= Nov 10, 2009 9:21:25 AM b= Nov 10, 2009 10:21:25 AM I want to find difference between the a & b I googled and tried with some options but no luck. My OS is AIX (1 Reply)
Discussion started by: bandlan9
1 Replies

6. Shell Programming and Scripting

Difference between two timestamps Contd..

There was this thread earlier with the same name and the solution provided was excellent. Here is the solution to find diffrenc between two timestamp $ cat timestamp #! /usr/bin/ksh echo enter first time stamp read TIME1 echo enter second time stamp read TIME2 H1=${TIME1%:+()}... (3 Replies)
Discussion started by: Shellslave
3 Replies

7. Shell Programming and Scripting

ls -e to find out File modification time in secs

Hi All, I would like to know the file modification time till seconds in Unix. So I tried ls -e and it worked fine. This Solaris 5.10 -rw-rw-r-- 1 test admin 22 Sep 12 11:01:37 2008 test_message But I am not able to run the same command in SOlaris 5.6 and also in AIX/HP Is there... (3 Replies)
Discussion started by: rahulkav
3 Replies

8. Solaris

Difference between two timestamps

I'm writting a script to find the difference between two timestamp. One field i get on delivery time of the file like 07:17 AM and other is my SLA time 06:30 AM I need to find the difference between these two time (time exceeded to meet SLA). Need some suggestions. (8 Replies)
Discussion started by: raman1605
8 Replies

9. UNIX for Dummies Questions & Answers

find command not giving file names accord. to timestamps

Currently iam working on solaris environment, Iam using find command to get list of all files between any two given dates. But the find command is not listing files accord. to timestamp. I tried using -exec option as -exec ls -ltr {} \; Still the files are not listed according to timestamp..... (8 Replies)
Discussion started by: thanuman
8 Replies

10. Shell Programming and Scripting

Find command to get the timestamps

I want to have the timestamps of the files containing a specific string in them. I have tried using different combinations of find command and grep and ls but not giving the desired output. find $HOME/bin/shells -name "*" -print -exec ls -Flt {} -exec grep -i "abc" '{}' \; Please help. (8 Replies)
Discussion started by: nguda
8 Replies
Login or Register to Ask a Question