How do I read a file which is constantly updating?

前端 未结 6 516
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 15:41

I am getting a stream of data (text format) from an external server and like to pass it on to a script line-by-line. The file is getting appended in a continuous manner. Whi

6条回答
  •  借酒劲吻你
    2020-12-13 16:40

    The solutions to read the whole fine to seek to the end are perfomance-unwise. If that happens under Linux, I would suggest just to rename the log file. Then, you can scan all the entites in the renamed file, while those in original file will be filled again. After scanning all the renamed file - delete it. Or move whereever you like. This way you get something like logrotate but for scanning newly arriving data.

提交回复
热议问题