在运行脚本时,有时需要统计脚本执行的时间。在脚本中可以加入如下代码。
#!/bin/sh
time=`date +%Y%m%d-%H:%M`
echo "$time"
start_time_sec = `date +%s`
end_time_sec = `date +%s`
total_time = $($end_time_sec - $start_time_sec)
echo "Total: $total_time seconds."
在运行脚本时,有时需要统计脚本执行的时间。在脚本中可以加入如下代码。
#!/bin/sh
time=`date +%Y%m%d-%H:%M`
echo "$time"
start_time_sec = `date +%s`
end_time_sec = `date +%s`
total_time = $($end_time_sec - $start_time_sec)
echo "Total: $total_time seconds."