How to use tail -f recursively on a directory and its sub-directories?

喜夏-厌秋 提交于 2019-12-11 16:12:35

问题


I am trying to use tail utility in linux to monitor the logs present under nested directories. I tried using tail -f /var/log/**/* but this only go till direct child of log directory. It does not dig beyond one level. Basically I am trying to tail all the application logs in docker container and pass them to /proc/1/fd/1, so that they appear under docker logs.


回答1:


You need to enable

 shopt -s globstar

if it is disabled in your shell.

With this setting enabled, Bash will recurse directories with **.

This is not a feature of Docker or tail, it is a feature of your shell.



来源:https://stackoverflow.com/questions/58101405/how-to-use-tail-f-recursively-on-a-directory-and-its-sub-directories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!