如何等待消息出现在登录Shell中 [英] How to wait for message to appear in log in shell

查看:44
本文介绍了如何等待消息出现在登录Shell中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能否提供整洁的解决方案来阻止脚本执行,直到文本片段出现在给定文件中?

Could you please provide neat solution to block execution of the script until text snippet appear in the given file?

推荐答案

永远等待

grep -q 'ProducerService started' <(tail -f logs/batch.log)

等待超时

timeout 30s grep -q 'ProducerService started' <(tail -f logs/batch.log)

等待超时,通知错误

timeout 30s grep -q 'ProducerService started' <(tail -f logs/batch.log) || exit 1  

这篇关于如何等待消息出现在登录Shell中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆