tail command showing log file contents in non-real time

丶灬走出姿态 提交于 2020-01-06 08:39:51

问题


I have a C++ application (on Solaris 10) that shows log output based on the time chronological transactions. For example, before establishing a connection to Database server, it prints in stdout as: "Connecting to DB" and after the call to connect, if successful, says "Connected to DB", if failed, says, "failed to connect to DB" and so on. Now, when the application is run, the output (stdout) gets redirected to a log file as below:

appl > app.log

And, on another session, to see what's going on, I view as:

tail -f app.log

tail -f command is supposed to run in an endless loop, sleeping for a second and then attempt to read and copy lines from app.log and show on console. This helps to monitor what's going on in app.log While I see the ordering of outputs maintained, I see that sometimes outputs are coming many lines together as a chunk and then waiting, and it's not in real-time as things are happening. Is it because of the sleep and pull behavior of tail -f? Please help me to understand why it is not in real time. Or is there any other way to get a feel of real time?


回答1:


Try using the watch command on this file with an interval of 5 seconds and see if its having the same behavior as tail. If the write to the file app.log is missing in real-time similar will be the output in tail.



来源:https://stackoverflow.com/questions/33166123/tail-command-showing-log-file-contents-in-non-real-time

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