shell脚本对代码执行时间的计时

 

时间秒: $(date +%s)

算数表达式:

$(($cost_time/60))

$(($cost_time%60))

#!/bin/bash

# ccache is from epel mirrors:http://mirrors.xxxx.com.cn/epel/7Server/x86_64/
start_time=$(date +%s)
sleep 1

#sudo mock -r xxxx-v5.05-x86_64 --rebuild kernel-3.10.0-957.1.3.el7.xxxx.gd2389d1.src.rpm --no-clean --no-cleanup-after

end_time=$(date +%s)
cost_time=$[ $end_time-$start_time ]
echo "build kernel time is $(($cost_time/60))min $(($cost_time%60))s"

  

posted @ 2019-09-03 20:51  无边身尊者  阅读(10408)  评论(1编辑  收藏  举报