date_time=`date +"%Y%m%d%H%M"`
//截取想要的时间
date_d=${date_time:0:8}
date_H=${date_time:8:2}
date_M=${date_time:10:2}
date_5_ago=`date -d "${date_d} ${date_H}:${date_M} 5 minute ago" +"%Y%m%d%H%M"` //计算已知时间的前XX分钟
time1=`date -d "$date_5_ago" +%s `
time2=`date -d "$date_time" +%s`
time=$(($time1 - $time2))
time_c=`date -d @$time "+%M"`
starttime=`date +'%Y-%m-%d %H:%M:%S'`
//执行代码
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"