h=$(date +%H)
s=$(date +%S)
m=$(date +%M)
附:摘自《Linux shell脚本攻略(第2版)》的日期格式表
shell--判断执行脚本所花费的时间
#!/bin/bash
starttime=$(date +%s)
sleep 5
endtime=$(date +%s)
cost=$((endtime - starttime))
echo $cost
相关文章: