linux使用总结(更新中...)

1、获取程序运行时间-linux shell脚本

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.

其中:

  • date +%s获取当前的纪元时(Unix时间),即自世界标准时间(UTC)1970年1月1日0时0分0秒起流逝的秒数。
  • sleep 5使程序延时5秒钟。
  • take=$(( end - start ))计算这段程序开始和结束之间流逝的秒数。

转自:https://www.jianshu.com/p/69d6a787aa93

原文地址:https://www.cnblogs.com/xuelisheng/p/12329845.html