Sponsored Content
Top Forums Shell Programming and Scripting How to calculate time difference between start and end time of a process! Post 302450401 by frans on Thursday 2nd of September 2010 01:05:47 PM
Old 09-02-2010
With GNU date

Code:
#!/bin/bash
StartDate="08/05/10 12:55"
EndDate="08/09/10 06:50"
HRS=$((($(date -d "$EndDate" +%s)-$(date -d "$StartDate" +%s))/3600))
WHRS=$HRS
for (( D=1; D<$((HRS/24+1)); D++ ))
do
   [ $(date -d "$StartDate $D days" +%u) -ge 6 ] && ((WHRS-=24))
done
echo "Working time elapsed='$WHRS'"

As a function
Code:
#!/bin/bash
Elapsed()	{
   HRS=$((($(date -d "$2" +%s)-$(date -d "$1" +%s))/3600))
   WHRS=$HRS
   for (( D=1; D<$((HRS/24+1)); D++ ))
   do
      [ $(date -d "$1 $D days" +%u) -ge 6 ] && ((WHRS-=24))
   done
   echo $WHRS
}
StartDate="08/05/10 12:55"
EndDate="08/09/10 06:50"
echo "Working time elapsed='$(Elapsed "$StartDate" "$EndDate")'"

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Start time/end time and status of crontab job

Is there anyway to get the start time and end time / status of a crontab job which was just completed? Of course, we know the start time of the crontab job since we are scheduling. But I would like to know process start and time recorded somewhere or can be fetched from a command like 'ps'. ... (3 Replies)
Discussion started by: thambi
3 Replies

2. Shell Programming and Scripting

How to calculate this time difference

Hi, Please help me in calculating the time difference between below mentioned timestamps. a=07/17/2007 02:20:00 AM MST b=07/17/2007 02:07:46 AM MST Thanks (2 Replies)
Discussion started by: Prat007
2 Replies

3. Shell Programming and Scripting

How to calculate the time difference...

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. ssh -l ora${sid} ${primaryhost} "tail -2 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" |head -1 | awk '{print echo "PREVIOUS:-- Start Date&Time: " $3,$4,echo "|| End Date&Time:... (1 Reply)
Discussion started by: suri.tyson
1 Replies

4. Shell Programming and Scripting

How to calculate the time difference.

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. ssh -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" | awk '{print $3,$4,$5,$6}' >> ${RESULTFILE} The output comes as below: 2008-09-30 06.00.01... (2 Replies)
Discussion started by: suri.tyson
2 Replies

5. Shell Programming and Scripting

How to get data between the start time and end time?

Hi, Can anyone help me how can I get the line that between the start time and end time. file1.txt 15/03/2009 20:45:03 Request: - Data of this line 15/03/2009 20:45:12 Response: - Data of this line 15/03/2009 22:10:40 Request: - Data of this line 15/03/2009 22:10:42 Response: - Data of... (1 Reply)
Discussion started by: tanit
1 Replies

6. Linux

Process start time not showing correct time

Process start time is not showing the correct time: I had started a process on Jun 17th at 23:30:00. Next day morning when I run the command "ps -ef | grep mq", the process is showing the start date of Jun 17th but the start time is 00:16:41 Day/Date is setup correctly on the server. It... (2 Replies)
Discussion started by: hemangjani
2 Replies

7. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

8. Shell Programming and Scripting

Calculate time difference

I have time in a file in HH:MM:SS format as it contents(its not the file creation time). i need this to be converted to epoch time or time since 1970. The time is written into that file by a script, which i cannot modify. Im using AIX machine $ cat abc.txt 10:29:34 (2 Replies)
Discussion started by: gpk_newbie
2 Replies

9. Shell Programming and Scripting

Calculate time difference between two lines

i grepped the time stamp in a file as given below now i need to calculate time difference file data: 18:29:10 22:15:50 (5 Replies)
Discussion started by: vivekn
5 Replies
DNSSEC-SIGNZONE(8)														DNSSEC-SIGNZONE(8)

NAME
dnssec-signzone - DNSSEC zone signing tool SYNOPSIS
dnssec-signzone [ -a ] [ -c class ] [ -d directory ] [ -s start-time ] [ -e end-time ] [ -f output-file ] [ -h ] [ -i interval ] [ -n nthreads ] [ -o origin ] [ -p ] [ -r randomdev ] [ -t ] [ -v level ] zonefile [ key... ] DESCRIPTION
dnssec-signzone signs a zone. It generates NXT and SIG records and produces a signed version of the zone. If there is a signedkey file from the zone's parent, the parent's signatures will be incorporated into the generated signed zone file. The security status of delegations from the the signed zone (that is, whether the child zones are secure or not) is determined by the presence or absence of a signedkey file for each child zone. OPTIONS
-a Verify all generated signatures. -c class Specifies the DNS class of the zone. -d directory Look for signedkey files in directory as the directory -s start-time Specify the date and time when the generated SIG records become valid. This can be either an absolute or relative time. An absolute start time is indicated by a number in YYYYMMDDHHMMSS notation; 20000530144500 denotes 14:45:00 UTC on May 30th, 2000. A relative start time is indicated by +N, which is N seconds from the current time. If no start-time is specified, the current time is used. -e end-time Specify the date and time when the generated SIG records expire. As with start-time, an absolute time is indicated in YYYYMMDDHHMMSS notation. A time relative to the start time is indicated with +N, which is N seconds from the start time. A time realtive to the current time is indicated with now+N. If no end-time is specified, 30 days from the start time is used as a default. -f output-file The name of the output file containing the signed zone. The default is to append .signed to the input file. -h Prints a short summary of the options and arguments to dnssec-signzone. -i interval When a previously signed zone is passed as input, records may be resigned. The interval option specifies the cycle interval as an offset from the current time (in seconds). If a SIG record expires after the cycle interval, it is retained. Otherwise, it is con- sidered to be expiring soon, and it will be replaced. The default cycle interval is one quarter of the difference between the signature end and start times. So if neither end-time or start-time are specified, dnssec-signzone generates signatures that are valid for 30 days, with a cycle interval of 7.5 days. There- fore, if any existing SIG records are due to expire in less than 7.5 days, they would be replaced. -n ncpus Specifies the number of threads to use. By default, one thread is started for each detected CPU. -o origin The zone origin. If not specified, the name of the zone file is assumed to be the origin. -p Use pseudo-random data when signing the zone. This is faster, but less secure, than using real random data. This option may be use- ful when signing large zones or when the entropy source is limited. -r randomdev Specifies the source of randomness. If the operating system does not provide a /dev/random or equivalent device, the default source of randomness is keyboard input. randomdev specifies the name of a character device or file containing random data to be used instead of the default. The special value keyboard indicates that keyboard input should be used. -t Print statistics at completion. -v level Sets the debugging level. zonefile The file containing the zone to be signed. Sets the debugging level. key The keys used to sign the zone. If no keys are specified, the default all zone keys that have private key files in the current directory. EXAMPLE
The following command signs the example.com zone with the DSA key generated in the dnssec-keygen man page. The zone's keys must be in the zone. If there are signedkey files associated with this zone or any child zones, they must be in the current directory. example.com, the following command would be issued: dnssec-signzone -o example.com db.example.com Kexample.com.+003+26160 The command would print a string of the form: In this example, dnssec-signzone creates the file db.example.com.signed. This file should be referenced in a zone statement in a named.conf file. SEE ALSO
dnssec-keygen(8), dnssec-signkey(8), BIND 9 Administrator Reference Manual, RFC 2535. AUTHOR
Internet Software Consortium BIND9 June 30, 2000 DNSSEC-SIGNZONE(8)
All times are GMT -4. The time now is 10:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy