-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathafterjob.sh
42 lines (34 loc) · 855 Bytes
/
afterjob.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
client=$1
# read the value the before script generated
starttime=`cat /tmp/$client.timemetric`
endtime=`date +%s`
timetaken=$(($endtime - $starttime))
# stolen function to convert seconds to friendly notation - credit http://stackoverflow.com/a/12199816 choroba
function show_time () {
num=$1
min=0
hour=0
day=0
if((num>59));then
((sec=num%60))
((num=num/60))
if((num>59));then
((min=num%60))
((num=num/60))
if((num>23));then
((hour=num%24))
((day=num/24))
else
((hour=num))
fi
else
((min=num))
fi
else
((sec=num))
fi
ttaken=""$hour"h "$min"m "$sec"s"
}
show_time $timetaken
## Do something with ttaken value. I add it to a database.