在shell腳本中統計程序執行完畢所需要的時間不像在java中使用System.currentTimeMillis()方便
稍微記錄一下,以供備用,免得又去花時間想(統計程序執行消耗多少s):
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"