我有一个用于跟踪日志文件以确定服务器是否已启动的脚本,它是这样的:
echo "Starting server."
./start_server.sh
sleeptime=0
while [ ${sleeptime} -lt 60 ]
do
sleep 5
serverlog=$(tail -n 5 ./server.log)
echo ${serverlog} | grep -iq "Server startup"
if [ $? = 0 ]
then
echo "Server startup successful"
exit 0
fi
let sleeptime=sleeptime+5
done
echo "Warning: server startup status unknown."
exit 1
当我运行脚本(./start_server.sh)时,脚本退出正常。但是,当我将它传送到 tee (./start_server.sh | tee -a serverstartup.log) 时,除非我强制执行 (ctrl + C),否则脚本不会结束。
为什么流水线到 tee 时脚本不退出?