Query - date command | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Query - date command

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-25-2013
nag_sathi nag_sathi is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 21 July 2014, 1:26 AM EDT
Location: INDIA
Posts: 60
Thanks: 43
Thanked 1 Time in 1 Post
Query - date command

Hi,

I am trying to capture the total run time of a script which contains SQL's by providing date command in top & bottom, it displaying both the times same in top & bottom.However the time in the sql connection is different.Please help.

OS - LINUX
Shell - ksh



Code:
printf "Script Started at $date" >> $LOGFILE
sqlplus userid/pwd test1.sql
.
.
.
sqlplus userid/pwd testn.sql
printf "Script Ended at $date" >> $LOGFILE

Sponsored Links
    #2  
Old 03-25-2013
in2nix4life's Avatar
in2nix4life in2nix4life is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 23 July 2014, 10:14 AM EDT
Location: East Coast
Posts: 593
Thanks: 1
Thanked 170 Times in 156 Posts
It seems you're storing the date in a variable somewhere in your script which is fine, however, if you need a start and end date then you will need to store the date command again.


Code:
$date=$(date)
printf "Script Started at $date" >> $LOGFILE
sqlplus userid/pwd test1.sql
.
.
.
sqlplus userid/pwd testn.sql
$date=$(date)
printf "Script Ended at $date" >> $LOGFILE

The Following User Says Thank You to in2nix4life For This Useful Post:
nag_sathi (03-25-2013)
Sponsored Links
    #3  
Old 03-25-2013
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
Moderator
 
Join Date: Jan 2007
Last Activity: 23 July 2014, 11:07 AM EDT
Location: Варна, България / Milano, Italia
Posts: 5,663
Thanks: 182
Thanked 616 Times in 574 Posts
You could use:

Code:
printf 'Script Started at %s\n' "$( date )" >> $LOGFILE
sqlplus userid/pwd test1.sql
.
.
.
sqlplus userid/pwd testn.sql
printf 'Script Ended at %s\n' "$( date )" >> $LOGFILE

Note that if you add set time on timing on at the top of your SQL commands,
you'll get the current and the elapsed time in your sqlplus output.

Last edited by radoulov; 03-25-2013 at 10:07 AM..
The Following User Says Thank You to radoulov For This Useful Post:
nag_sathi (03-25-2013)
    #4  
Old 03-25-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 23 July 2014, 12:06 PM EDT
Location: Galactic Empire
Posts: 3,354
Thanks: 230
Thanked 1,190 Times in 1,123 Posts
You can also use time command to print elapsed time for sqlplus utility:

Code:
time sqlplus username/password@instance

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date Query theref UNIX for Dummies Questions & Answers 2 01-17-2011 08:55 AM
Query regarding date field in shell script kavithakuttyk Shell Programming and Scripting 1 10-03-2009 07:49 AM
Date & NUmber Validation Query alok_jax Shell Programming and Scripting 4 01-05-2005 06:51 PM
Date change related query franklo UNIX for Dummies Questions & Answers 2 09-04-2002 09:41 PM
Unix Date query csong2 UNIX for Advanced & Expert Users 5 10-29-2001 01:58 PM



All times are GMT -4. The time now is 12:06 PM.