Calculating End Date and time, if the script aborts
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > Calculating End Date and time, if the script aborts




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Calculating End Date and time, if the script aborts  
BN


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-06 12:21 AM

Greetings,

I am writing a Kshell script  for hp-ux, aix, sun to  insert  into
database,
the start_date_time, end_date_time, status from the backup log files.

If the backup is successful , I am able to get the  end_date_time, BUT
if for some reason backup aborted, I  have no idea on how to get the
end_date_time.

Here is the output of  the log file when backup aborted:

Backup started 12/19/2006 23:02:34

23:02:35 Initiating backup
23:02:45 INF - Processing /bu1/orabk/mydb
23:02:45 /
23:02:45 /bu1/
23:02:45 /bu1/orabk/
23:02:45 /bu1/orabk/vrwcdb/
23:02:45 /bu1/orabk/vrwcdb/db/
23:02:45 /bu1/orabk/vrwcdb/db/current/
23:02:47 INF - Waiting for mount of media id
. . . . .. . . .

02:01:47 INF - Waiting for mount of media id S06272 on server vrttds02
for writing.
02:31:42 ERR - Timed out waiting for the media to be mounted and
positioned.
02:31:42 ERR - Timed out waiting for the media to be mounted and
positioned.
02:31:46 ERR - bpbkar exiting because backup is aborting
02:31:46 ERR - bpbkar killed by SIGPIPE
Program is:/apps/opt/oracle/dbascripts/rman/bk2tape_db.ksh exit status
is:52

The last time stamp is at 02:31:46 which is next day, since the backup
has started at 23:02:35

so the
start_date_time="12/19/2006 23:02:34"
end_date_time = "12/20/2006  02:31:46"

The Backup need not have to start at 23:06:35 every day, some times it
can start  after 00:00 hrs
some thing like 01:05:02  and ends the same day.

so the
start_date_time="12/20/2006   01:05:02"
end_date_time = "12/20/2006  03:31:46"


How can I do this.

Regards & thanks
BN






[ Post a follow-up to this message ]



    Re: Calculating End Date and time, if the script aborts  
Janis Papanagnou


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-06 06:29 AM

BN wrote:
> Greetings,
>
> I am writing a Kshell script  for hp-ux, aix, sun to  insert  into
> database,
> the start_date_time, end_date_time, status from the backup log files.
>
> If the backup is successful , I am able to get the  end_date_time, BUT
> if for some reason backup aborted, I  have no idea on how to get the
> end_date_time.

Just print the start and end date before resp. after you call your
backup program...

echo Startdate: $(date)
do_DB_backup
echo Enddate: $(date)

Or make clear what your problem could be.

Janis

>
> Here is the output of  the log file when backup aborted:
>
> Backup started 12/19/2006 23:02:34
>
> 23:02:35 Initiating backup
> 23:02:45 INF - Processing /bu1/orabk/mydb
> 23:02:45 /
> 23:02:45 /bu1/
> 23:02:45 /bu1/orabk/
> 23:02:45 /bu1/orabk/vrwcdb/
> 23:02:45 /bu1/orabk/vrwcdb/db/
> 23:02:45 /bu1/orabk/vrwcdb/db/current/
> 23:02:47 INF - Waiting for mount of media id
> . . . . .. . . .
>
> 02:01:47 INF - Waiting for mount of media id S06272 on server vrttds02
> for writing.
> 02:31:42 ERR - Timed out waiting for the media to be mounted and
> positioned.
> 02:31:42 ERR - Timed out waiting for the media to be mounted and
> positioned.
> 02:31:46 ERR - bpbkar exiting because backup is aborting
> 02:31:46 ERR - bpbkar killed by SIGPIPE
> Program is:/apps/opt/oracle/dbascripts/rman/bk2tape_db.ksh exit status
> is:52
>
> The last time stamp is at 02:31:46 which is next day, since the backup
> has started at 23:02:35
>
> so the
> start_date_time="12/19/2006 23:02:34"
>  end_date_time = "12/20/2006  02:31:46"
>
> The Backup need not have to start at 23:06:35 every day, some times it
> can start  after 00:00 hrs
> some thing like 01:05:02  and ends the same day.
>
> so the
> start_date_time="12/20/2006   01:05:02"
>  end_date_time = "12/20/2006  03:31:46"
>
>
> How can I do this.
>
> Regards & thanks
> BN
>





[ Post a follow-up to this message ]



    Re: Calculating End Date and time, if the script aborts  
Ed Morton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-06 06:29 AM

BN wrote:
> Greetings,
>
> I am writing a Kshell script  for hp-ux, aix, sun to  insert  into
> database,
> the start_date_time, end_date_time, status from the backup log files.
>
> If the backup is successful , I am able to get the  end_date_time, BUT
> if for some reason backup aborted, I  have no idea on how to get the
> end_date_time.
>
> Here is the output of  the log file when backup aborted:
>
> Backup started 12/19/2006 23:02:34
>
> 23:02:35 Initiating backup
> 23:02:45 INF - Processing /bu1/orabk/mydb
> 23:02:45 /
> 23:02:45 /bu1/
> 23:02:45 /bu1/orabk/
> 23:02:45 /bu1/orabk/vrwcdb/
> 23:02:45 /bu1/orabk/vrwcdb/db/
> 23:02:45 /bu1/orabk/vrwcdb/db/current/
> 23:02:47 INF - Waiting for mount of media id
> . . . . .. . . .
>
> 02:01:47 INF - Waiting for mount of media id S06272 on server vrttds02
> for writing.
> 02:31:42 ERR - Timed out waiting for the media to be mounted and
> positioned.
> 02:31:42 ERR - Timed out waiting for the media to be mounted and
> positioned.
> 02:31:46 ERR - bpbkar exiting because backup is aborting
> 02:31:46 ERR - bpbkar killed by SIGPIPE
> Program is:/apps/opt/oracle/dbascripts/rman/bk2tape_db.ksh exit status
> is:52
>
> The last time stamp is at 02:31:46 which is next day, since the backup
> has started at 23:02:35
>
> so the
> start_date_time="12/19/2006 23:02:34"
>  end_date_time = "12/20/2006  02:31:46"
>
> The Backup need not have to start at 23:06:35 every day, some times it
> can start  after 00:00 hrs
> some thing like 01:05:02  and ends the same day.
>
> so the
> start_date_time="12/20/2006   01:05:02"
>  end_date_time = "12/20/2006  03:31:46"
>
>
> How can I do this.
>
> Regards & thanks
> BN
>

Using GNU awk and assuming it doesn't take more than a day for the
backup to complete:

$ cat file
Backup started 12/19/2006 23:02:34

23:02:35 Initiating backup
23:02:45 INF - Processing /bu1/orabk/mydb
23:02:45 /
23:02:45 /bu1/
23:02:45 /bu1/orabk/
23:02:45 /bu1/orabk/vrwcdb/
23:02:45 /bu1/orabk/vrwcdb/db/
23:02:45 /bu1/orabk/vrwcdb/db/current/
23:02:47 INF - Waiting for mount of media id
. . . . .. . . .

02:01:47 INF - Waiting for mount of media id S06272...
02:31:42 ERR - Timed out waiting for the media to....
02:31:42 ERR - Timed out waiting for the media to...
02:31:46 ERR - bpbkar exiting because backup is aborting
02:31:46 ERR - bpbkar killed by SIGPIPE
Program is:/apps/opt/oracle/dbascripts/rman/bk2tape_db.ksh...
$
$
$ cat getdates.awk
/Backup started/ { startDate = $3; startTime = $4 }
$1 ~ /[0-9]/ { endTime = $1 }
END {
split(startDate":"startTime,a,/[:/]/)
startSecs = mktime(a[3]" "a[1]" "a[2]" "a[4]" "a[5]" "a&
#91;6])

split(startDate":"endTime,a,/[:/]/)
endSecs = mktime(a[3]" "a[1]" "a[2]" "a[4]" "a[5]" "a	
1;6])

endDate = ( endSecs > startSecs ? startDate :
strftime("%m/%d/%Y",endSecs + 24 * 60 * 60) )

printf "Start Date/Time: %s %s\n",startDate,startTime
printf "End Date/Time  : %s %s\n",endDate,endTime
}
$
$
$ awk -f getdates.awk file
Start Date/Time: 12/19/2006 23:02:34
End Date/Time  : 12/20/2006 02:31:46
$

Regards,

Ed.





[ Post a follow-up to this message ]



    Re: Calculating End Date and time, if the script aborts  
BN


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-06 12:31 PM


Ed Morton wrote:
> BN wrote: 
>
> Using GNU awk and assuming it doesn't take more than a day for the
> backup to complete:
>
> $ cat file
> Backup started 12/19/2006 23:02:34
>
> 23:02:35 Initiating backup
> 23:02:45 INF - Processing /bu1/orabk/mydb
> 23:02:45 /
> 23:02:45 /bu1/
> 23:02:45 /bu1/orabk/
> 23:02:45 /bu1/orabk/vrwcdb/
> 23:02:45 /bu1/orabk/vrwcdb/db/
> 23:02:45 /bu1/orabk/vrwcdb/db/current/
> 23:02:47 INF - Waiting for mount of media id
> . . . . .. . . .
>
> 02:01:47 INF - Waiting for mount of media id S06272...
> 02:31:42 ERR - Timed out waiting for the media to....
> 02:31:42 ERR - Timed out waiting for the media to...
> 02:31:46 ERR - bpbkar exiting because backup is aborting
> 02:31:46 ERR - bpbkar killed by SIGPIPE
> Program is:/apps/opt/oracle/dbascripts/rman/bk2tape_db.ksh...
> $
> $
> $ cat getdates.awk
> /Backup started/ { startDate = $3; startTime = $4 }
> $1 ~ /[0-9]/ { endTime = $1 }
> END {
>          split(startDate":"startTime,a,/[:/]/)
>          startSecs = mktime(a[3]" "a[1]" "a[2]" "a[4]" "a&
#91;5]" "a[6])
>
>          split(startDate":"endTime,a,/[:/]/)
>          endSecs = mktime(a[3]" "a[1]" "a[2]" "a[4]" "a	
1;5]" "a[6])
>
>          endDate = ( endSecs > startSecs ? startDate :
>                          strftime("%m/%d/%Y",endSecs + 24 * 60 * 60) )
>
>          printf "Start Date/Time: %s %s\n",startDate,startTime
>          printf "End Date/Time  : %s %s\n",endDate,endTime
> }
> $
> $
> $ awk -f getdates.awk file
> Start Date/Time: 12/19/2006 23:02:34
> End Date/Time  : 12/20/2006 02:31:46
> $
>
> Regards,
>
> 	Ed.

Greetings,

Thank you very much.

Why do you say
"assuming it doesn't take more than a day for the backup to complete:"

Is the Logic going to change?

If I cannot use gawk (not to have it on Production Servers - Company
Policy)
Is there any other way I can do this.

Regards & Thanks
BN






[ Post a follow-up to this message ]



    Re: Calculating End Date and time, if the script aborts  
Ed Morton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-06 06:20 PM

BN wrote:

> Ed Morton wrote:
> 
>
>
> Greetings,
>
> Thank you very much.
>
> Why do you say
> "assuming it doesn't take more than a day for the backup to complete:"

Because I change the date to the next day if the originally calculated
end date/time appears to be earlier than the start date/time.

> Is the Logic going to change?

Yes. You'd need to check the timestamps all the way through the log file
looking for them rolling round N times to identify N days, and then
you'd be relying on there never being more than 24 hours between
timestamps in the file or there'd be no way to spot days being skipped.

> If I cannot use gawk (not to have it on Production Servers - Company
> Policy)
> Is there any other way I can do this.

Sure, write your own versions of mktime() and strftime().

Ed.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:14 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register