-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript-runtime.sh
More file actions
executable file
·29 lines (22 loc) · 932 Bytes
/
script-runtime.sh
File metadata and controls
executable file
·29 lines (22 loc) · 932 Bytes
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
#!/bin/bash
# Skript Laufzeit berechnen
# by A.Laub andreas[-at-]laub-home.de
# Sekundenzaehler starten ########################################
anfang=$(date +%s)
##################################################################
###Skript Aufrufe#################################################
echo "Schlafen für 10s"
sleep 10
##################################################################
# Sekundenzaehler stoppen ########################################
ende=$(date +%s)
# benoetigte Zeit in Sekunden berechnen ##########################
diff=$[ende-anfang]
# Prüfen, ob benoetigte Zeit kleiner als 60 sec ##################
if [ $diff -lt 60 ]; then
echo -e 'Runtime '$diff' secs'
# Wenn gleich oder groeßer 60 Sekunden, ##########################
# in Minuten und Sekunden umrechnen ##############################
elif [ $diff -ge 60 ]; then
echo -e 'Runtime '$[$diff / 60] 'min(s) '$[$diff % 60] 'secs'
fi