LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tail new file (https://www.linuxquestions.org/questions/linux-newbie-8/tail-new-file-916159/)

Fracker 11-29-2011 05:21 AM

tail new file
 
We have a process which generate logs, when log size reaches to a size limit, it start generating a new file.

Some operators are meant to monitor these logs continuously. We are using created a menu for operators to tail -f which display logs on the screen. But the problem is, after some time tail -f stops since log file changes. and operator needs to relogin to change the logs. Is their any way, which automatically change the log file, when it don't update for some time.

_bsd 11-29-2011 05:49 AM

Code:

eg: tail --follow=name /path/file2follow
when the file gets moved/archived tail will follow the new file

you'll see a message similar to the following

$ tail --follow=name foo
data line1
data line2
data line3
data line4
data line5
tail: foo: No such file or directory
tail: `foo' has appeared; following end of new file
data line6
...

Fracker 11-30-2011 07:23 AM

But here file don't get renamed but new file generates with new name. we normally use ls -ltr | tail -n 1

_bsd 11-30-2011 08:11 AM

have file moved, compressed. new file created, symlink to file.
look in /var/log, see how logs are moved, compressed.

If you can either keep same name or use a symlink, the command I gave you will work


All times are GMT -5. The time now is 08:08 AM.