首页 > 系统服务 > 详细

linux shell 命令之SECONDS

时间:2021-03-29 20:30:33      阅读:31      评论:0      收藏:0      [点我收藏+]

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

linux shell 命令之SECONDS

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!