compare the log and display the time difference..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting compare the log and display the time difference..
# 1  
Old 01-28-2009
compare the log and display the time difference..

Hi All,
I've written a script which reads all the systems backup information and saves it in a log file.

#!/bin/ksh
export ORACLE_SID=$1
export primaryhost=$2
export sid=`echo $ORACLE_SID| tr ['A-Z'] ['a-z']`
RESULTFILE=/oracle/PC9/backupstatus_prod.log

LOGP=`ssh -o StrictHostKeyChecking=no -l ora${sid} ${primaryhost} "tail -2 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" |head -1 | awk '{print $3,$4,$5,$6}'` >> ${RESULTFILE}

LOGL=`ssh -o StrictHostKeyChecking=no -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" | awk '{print echo "BEGIN:" $3,$4 echo "END:"$5,$6}'` >> ${RESULTFILE}


The output shows as below:
BEGIN:2009-01-25 02.00.49 END:2009-01-25 08.42.53

Now i need to calculate the current time with the last successfull backup end time and provide the elapsed time (i.e in HOURS).

Example : If the current date and time is 2009-01-28 04.32.57 and in the above output we see the last successful backup has finished at 2009-01-25 08.42.53 so it has to calculate the elapsed hours from then and display the hours...

Any help is highly appreciated...

Thank you ALL..
# 2  
Old 01-28-2009
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to find time difference between HTTP PUT and HTTP DELETE requests in access.log

Hi, I'm trying to write a script to determine the time gap between HTTP PUT and HTTP DELETE requests in the HTTP Servers access log. Normally client will do HTTP PUT to push content e.g. file_1.txt and 21 seconds later it will do HTTP DELETE, but sometimes the time varies causing some issues... (3 Replies)
Discussion started by: Juha
3 Replies

2. Shell Programming and Scripting

Check/Parse log file's lines using time difference/timestamp

I was looking at this script which outputs the two lines which differs less than one sec. #!/usr/bin/perl -w use strict; use warnings; use Time::Local; use constant SEC_MILIC => 1000; my $file='infile'; ## Open for reading argument file. open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies

3. Shell Programming and Scripting

Time difference between two time stamps

Hi Friends, I have 2 varaibles which contain START=`date '+ %m/%d/%y %H:%M:%S'` END=`date '+ %m/%d/%y %H:%M:%S'` i want the time difference between the two variables in Seconds. Plz help. (2 Replies)
Discussion started by: i150371485
2 Replies

4. Shell Programming and Scripting

Log Analysis with AWK with Time difference

I would like to write a shell script that calculated the time difference bettween the log entries. If the time difference is higher as 200 sec. print the complette lines out. My Problem is, i am unable to jump in the next line and calculate the time difference. Thank you for your Help. ... (5 Replies)
Discussion started by: fabian3010
5 Replies

5. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

6. Shell Programming and Scripting

Compare difference

Hi every body Help required file 1 aaaaa bbbb cccccc dddd ffff File 2 aaaaa,1,ee,44,5t,6y, cccccc, ..... dddd, ..... eeeeee, ..... ffff, ...... ggg, ....... (7 Replies)
Discussion started by: The_Archer
7 Replies

7. Shell Programming and Scripting

Compare Last Modified Time across Time Zone

Hi, I'm new to shell script programming, I only have Java programming background. I'm writing a shell script to do file synchronization between 2 machines that located at different time zone area. Both machine were set its time zone according to its geographical location (Eg: server is at... (1 Reply)
Discussion started by: python
1 Replies

8. Shell Programming and Scripting

Script to display time difference..

Hi i've written a script which reads last two line of the log file from N number of servers and send the mail by redirecting to a particular log file. And the two lines is displayed below. Oracle Q03 Begin Hot BACKUP Time: 07/23/08 18:35:46 Oracle Q03 End Hot BACKUP Time: 07/24/08 14:18:15... (1 Reply)
Discussion started by: suri.tyson
1 Replies

9. UNIX for Dummies Questions & Answers

Need to get 4 Hrs back time and compare with successive time

Hi all, I am working on a script in which i need to get 4 hrs back time from the current time which i got from this perl function : `perl -e 'print localtime(time() - 14400) . "\n"'` now i need to get this in a loop and increment that time by 15 minutes i.e i=900(=15minutes) `perl... (2 Replies)
Discussion started by: maanik85
2 Replies

10. Shell Programming and Scripting

To find the time difference between two lines of the same log file

Hello Friends, I want to write a script for the following: nlscux62:tibprod> grep "2008 Apr 30 01:" SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2.log | grep -i post | more 2008 Apr 30 01:01:23:928 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info AER3-000095 IDOC... (2 Replies)
Discussion started by: satyakam
2 Replies
Login or Register to Ask a Question