文章目录
- 1. 源码分析
- 2. shell脚本
1. 源码分析
执行前记录开始时间
执行脚本
记录记录结束时间
总耗时=结束时间-开始时间
2. shell脚本
#!/bin/bash
starttime=`date +'%Y-%m-%d %H:%M:%S'`
# 执行脚本程序
./xxxloadupgrade.sh
endtime=`date +'%Y-%m-%d %H:%M:%S'`
start_seconds=$(date --date="$starttime" +%s);
end_seconds=$(date --date="$endtime" +%s);
echo "本次运行时间: "$((end_seconds-start_seconds))"s"