Tailing Rolling Files

前端 未结 2 1734
别跟我提以往
别跟我提以往 2021-02-13 04:02

I have a directory full of rolling log files that I would like to be able to use tail on.

The files are named as such:

name      modified
00A.txt   Dec 2         


        
2条回答
  •  感情败类
    2021-02-13 04:43

    You can use the -F option for tail which implies --follow=name --retry.

    From the man page:

    -F      
    The -F option implies the -f option, but tail will also check to see if the 
    file being followed has been renamed or rotated.  The file is closed and 
    reopened when tail detects that the filename being read from has a new inode 
    number. The -F option is ignored if reading from standard input rather than 
    a file.
    

提交回复
热议问题