Hi,
I created a script for finding the duration of a job using the start and end time of the job. But the command doesnt calculate correct value if the duration is more than 24 hours. Any help would be really good
.
cat test1 --- start time
03/27/15 17:41:00
03/24/15 11:58:04
03/23/15 06:00:00
cat test2 --- end time
03/27/15 17:51:30
03/24/15 18:14:01
03/24/15 07:00:00
Calculating difference using the below command
let DIFF=(`date +%s -d "$b"` - `date +%s -d "$a"`) // calculating the duration in seconds
echo|date -u -d @${DIFF} +"%H"h" %M"m"" // converting into H:M format.
output
00h 10m -- correct value
06h 15m -- correct value
01h 00m -- In correct value . Instead of 25h printing 1h as its not deducting the day from 24 to 23.