1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/ksh
# Assign start and end times
start_time=$(date +'%Y-%m-%d %H:%M:%S')
# Perform some operations or tasks here
sleep 15 # Simulating a task taking some time
end_time=$(date +'%Y-%m-%d %H:%M:%S')
start_timestamp=$(date -d "$start_time" '+%s')
end_timestamp=$(date -d "$end_time" '+%s')
# Convert dates to Unix timestamps
# Calculate the time difference in seconds
time_diff=$((end_timestamp - start_timestamp))
# If you want to display the time in a more readable format (hours:minutes:seconds)
total_time=$(date -u -d@"$time_diff" +'%H:%M:%S')
echo "Total time : $total_time"
|