tail file if the name is changeable
Hi all i am facing a problem with tailing a log file. Logs of application located in one folder:
applog_20100101_0200.log <--log until 2 am january 1 applog_20100101_0456.log <--log until 4:56 am applog.log <-- current log Application can change log when ever it wants to. I need to monitor this log, what i do: tail -f applog.log But when app changes log my tail just stops. How can i tail applog.log all the time with out stops? Thanks in advance! |
Hi,
When you're tailing a file and that file gets renamed then it's normal that the tail fails. What you could do is write a script that restart the tail command when inactive for a certain amount of time. Kind regards, Eric |
from the manpage:
-f, --follow[={name|descriptor}] output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent --follow=name will follow the file by name, so if the file is moved, closed, and reopened during rotation, you'll start seeing the new file. |
If tail can do that, I have to ask why it doesn't use inotify rather than a (tight) loop to check the file.
|
I think its just because inotify is so new (at least compared to the gnu utils packages :) )
|
Quote:
Instead, also from the manpage Code:
-F same as --follow=name --retry Try Code:
tail -F applog.log Kind regards, Eric |
oh duh- I had no idea big F did that, you saved me some future typing erictra!
|
Hi,
No problem! You're welcome. Since you pointed out to the man page and I hardly use tail (only when troubleshooting something) I read through the man page myself and came across that one. Kind regards, Eric |
All times are GMT -5. The time now is 05:05 PM. |