datetime difference in seconds


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting datetime difference in seconds
# 1  
Old 05-31-2011
datetime difference in seconds

Hi,

I'm trying to find processing time of my script. Please can someone give me the commands to get the start/end time in "dd-mm-yyyy hh:mm:ss" and the differnce in seconds.

Quote:
Start Time : dd-mm-yyyy hh:mm:ss
End Time : dd-mm-yyyy hh:mm:ss
Processing Time (in secs) : {number of seconds}
Thanks!
# 2  
Old 05-31-2011
You just use time command to get it.

Code:
time <command>

# 3  
Old 05-31-2011
Quote:
Originally Posted by kumaran_5555
You just use time command to get it.

Code:
time <command>

Thanks, but i've to run my script part of a job, so it would be better if i've the time processing part of my script.
# 4  
Old 05-31-2011
Use POSIX time for date format
Code:
date "+%s"

It's much easier to do arithmetic operations on that format. If you substarct start date from end date in your script you will get how much the operation lasted in seconds.
If you need to convert standard time to POSIX time, perl and awk (strftime) support that.
# 5  
Old 05-31-2011
If you have access to a database (Sybase, Oracle), I find they make it much easier.
# 6  
Old 05-31-2011
If you want time info in a file :

Code:
echo start time: $(date +'%Y-%m-%d %H:%M:%S') >> time_info
(time <command>) 1>/dev/null 2>> time_info
echo end time: $(date +'%Y-%m-%d %H:%M:%S') >> time_info


You could use a wrapper script and schedule this in cron.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filename with datetime

Hello All, I need unix command to generate a file with datetime in it. For example : ABC_YYYYMMDDHH24MISS.txt Regards Biswajeet Ghosh (1 Reply)
Discussion started by: bghosh
1 Replies

2. Shell Programming and Scripting

SunOS compare datetime

Hi i need to compare the datetime between 2 columns. SunOS 5.1 is used. Notice that mktime seems like not supported. cat file2 P1,2012 12 4 21 36 48,2012 12 4 22 26 53 P2,2012 12 4 20 36 48,2012 12 4 21 21 23 P3,2012 12 4 18 36 48,2012 12 4 20 12 35 Below is the command used.... (1 Reply)
Discussion started by: chailee
1 Replies

3. UNIX for Dummies Questions & Answers

Find files between two datetime..

Hi All, How do i find all the files between two times. Eg: 26 may 2014 06:00 to 26 may 2014 14:00 mmin and mtime gives for a specific period. we receive hundreds of files input directories and i need to find how many files are received between given specific datetime. Thanks. (2 Replies)
Discussion started by: abhi_123
2 Replies

4. Shell Programming and Scripting

How to compare datetime?

Hi, To get the batch status, I will need to check if the particular job started after 5PM. if the job start time is before 5 pm, then it means that the job has not started for this particular date. I will run the script with date as argument. For eg: BS 07/10/2012 Start time from the log is... (8 Replies)
Discussion started by: ajayakunuri
8 Replies

5. Programming

SQL datetime calculation

Suppose I have a mysql table consisting of measurements taken during irregular intervals as follows: CREATE TABLE data (datetime DATETIME, value INTEGER); mysql> SELECT datetime, value FROM data; +---------------------+---------+ | datetime | value |... (2 Replies)
Discussion started by: figaro
2 Replies

6. Shell Programming and Scripting

Awk new datetime everyline

Hi, I'm using awk in HP-UX machine which does not support systime(), strftime(). So to get the date time I was using : seq 1 100000 | awk ' "date +%Y%m%d%H%M%s" | getline curtime; print curtime }' However the above code gets the date only once, next time it is not updated. For... (2 Replies)
Discussion started by: Random_Net
2 Replies

7. Shell Programming and Scripting

Time difference in seconds

date1=$(date +"%H:%M:%S") date2=$(date +"01:00:54") diff=$date2-$date1 echo $diff How to get the time difference in seconds. (4 Replies)
Discussion started by: sandy1028
4 Replies

8. Shell Programming and Scripting

datetime.pm

Hi, I'm trying to use datetime.pm function in Perl. I do not have in the library. Is there a way to get it and put it into library? Thanks, George. (1 Reply)
Discussion started by: gpaulose
1 Replies

9. Shell Programming and Scripting

Difference in day-hours-minutes-seconds format

Hi experts, I am reading two log files and passing dates as output to a txt file. Code is given below: echo "Start Time:" >> Report.txt cat start.log | while read LINE1 do echo $DATE1 >> Report.txt done echo "End Time:" >> Report.txt cat end.log | while read LINE2 ... (7 Replies)
Discussion started by: Sreejith_VK
7 Replies

10. UNIX for Advanced & Expert Users

Time Difference in seconds

It is required to calculate time difference in seconds between epoch time (19700101 00:00:00) and any given date time (e.g. 20010214 14:30:30). Is there any command in unix to get it? Thanks in adv. (1 Reply)
Discussion started by: k_bijitesh
1 Replies
Login or Register to Ask a Question