你能提供整洁的解决方案来阻止脚本的执行,直到文本片段出现在给定的文件中吗?
pgky5nke1#
永远等待
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
型
0yg35tkg2#
使用inotifywaitinotifywait有效地等待文件的更改例如:-1.终止要阻止的进程
inotifywait
inotifywait -q -e modify /path/to/file/containing/snippet
2条答案
按热度按时间pgky5nke1#
永远等待
字符串
等待超时
型
等待超时,通知错误
型
0yg35tkg2#
使用
inotifywait
inotifywait有效地等待文件的更改
例如:-
1.终止要阻止的进程
inotifywait -q -e modify /path/to/file/containing/snippet
个1.检查文件中的更改
1.如果更改匹配,则重新启动脚本