I have a piece of software that rotates its log files when it restarts. However, during development, I am restarting it a lot, so I would like to monitor the latest log file at any time.
If I start less
normally with less program.log
and hit Shift+f to tail, when the log file is rotated, I carry on monitoring the old log file. I assume this is because the inode number stays the same and less
has an open file handle to that inode.
Is it possible to monitor the latest activity on whatever log file is currently called program.log
?
Specifically, I am working on Sun OS, so a solution that works there would be ideal.
Best Answer
Use
less --follow-name
if your version ofless
supports it.That option was introduced in version 416.
Then do a normal follow command Shift+F within
less
.