1, acquisition program running time -linux shell script
1 #!/bin/bash 2 3 start=$(date +%s) 4 5 sleep 5; 6 7 end=$(date +%s) 8 take=$(( end - start )) 9 echo Time taken to execute commands is ${take} seconds.
among them:
date +%s
Getting the current era (Unix time), that is at 0:00 on January 1, 1970 the number of seconds elapsed from 0 seconds from Coordinated Universal Time (UTC).sleep 5
The program delay 5 seconds.take=$(( end - start ))
This program calculate the number of seconds elapsed between the beginning and the end.
Transfer: https://www.jianshu.com/p/69d6a787aa93