tail command showing log file contents in non-real

2019-09-08 12:00发布

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条回答
Anthone
2楼-- · 2019-09-08 12:33

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.

查看更多
登录 后发表回答