##SECONDS记录的是这个脚本运行的时间 #!/bin/bash count=1 MAX=5 while [[ "$SECONDS" -le "$MAX" ]] do echo "this is the $count time to sleep" let "count=$count+1" sleep 2 done echo "The running time of this scripts is $SECONDS" [root@server100 shell]# ./runsec.sh this is the 1 time to sleep this is the 2 time to sleep this is the 3 time to sleep The running time of this scripts is 6
转载于:https://blog.51cto.com/muahao/1531570