我正在跟踪这样的日志:
while [[ ! -n "${ready}" ]]; do
start_info=`grep "Ready" $LOG_FILE`
sleep 10
done
如果日志文件中没有“Ready”,这将永远持续下去,我怎样才能让它运行200秒?就像某种时间阈值。
谢谢
最佳答案
这可以避免重复 grep 整个文件:
start=$SECONDS
limit=200
while read -r line
do
if [[ $line =~ $ready ]]
then
start_info=$line
break
fi
if (( $SECONDS >= start + limit ))
then
break
fi
done < "$LOG_FILE"
关于linux - 跟踪日志直到达到特定时间阈值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4526627/