linux shell 命令之SECONDS

时间:2021-03-29 20:30:33   收藏:0   阅读:34

SECONDS记录脚本从开始执行到结束所耗费的时间,单位为秒

vi runsec.sh
#!/bin/bash

#定义两个变量:count 记录循环次数、MAX为while循环条件
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 script is $SECONDS"

./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 script is 6

原文:https://www.cnblogs.com/zhudaheng123/p/14593690.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!