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.

  • maybe tail -F program.log | less will work Commented May 1, 2013 at 8:09
  • tail -f program.log have you tried this ? Commented May 1, 2013 at 8:13

3 Answers 3


Use less --follow-name if your version of less supports it.
That option was introduced in version 416.

Then do a normal follow command Shift+F within less.

  • Excellent reply. Both Solaris 10 and Solaris 11 use less version 436 so this option is indeed available. Commented Jul 30, 2013 at 20:09

The less option --follow-name is only part of the solution;
To replace tail -F, another argument is needed:

less --follow-name +F file.log

The option alone like less --follow-name file.log does not actually start following the file updates. You need to enter the follow mode be pressing ShiftF.
(Exit the mode to navigate by ControlC.)

Instead of following the file, --follow-name modifies the behaviour of less.
It makes the command key ShiftF inside of less follow based on the file name, not the file descriptor.

Also, there is no normal option to start less in follow mode.
But you can use the command line to give keystrokes to execute after startup, by prefixing them with +.
Combining the modifier option with +F, less will actually start in the (modified) follow mode.

Use +F alone for the equivalent of plain tail -f:

less +F file.log

I just found the answer in this U&L Q&A titled: How to do a tail -f of log rotated files?.

Using tail:

(if installing GNU tail on your system is an option)

tail -F program.log

From the tail man page:

   -f,      --follow[={name|descriptor}]
            output appended data as the file grows; -f, 
            --follow, and --follow=descriptor are equivalent

   -F       same as --follow=name --retry

   --retry  keep  trying  to  open  a  file even when it is or becomes
            inaccessible; useful when following by name, i.e., with

The key is the --retry switch. This tells the tail command to keep retrying to follow a file by name. The -F switch does both a -f and a --retry.

Using less

As @StephaneChazela pointed out in the comments the following will not work.

tail -F program.log | less

The only other option you have is to use less directly assuming it supports the --follow-name switch and less the file directly, forgoing using tail completely.

less --follow-name program.log
  • I strongly dislike Sun OS sometimes... Commented May 1, 2013 at 8:39
  • I agree, I worked for years, it drives you nuts that the tooling is like 10 years old for some of the apps. Makes no sense. This site was invaluable for keeping your sanity on Solaris: sunfreeware.com/introduction.html
    – slm
    Commented May 1, 2013 at 8:43
  • if you want more sanity, check out pkgsrc.org :) Commented May 1, 2013 at 9:06
  • That won't work nicely. Because less will hang if you do "G" pr "F". Which you can interrupt by doing "Ctrl-C", but then it kills tail. You can then immune tail to Ctrl-C, but it's still not very usable. Commented May 1, 2013 at 9:47
  • With regards to GNU tail: Check out this for information about what tools should be available on any Solaris host. (Actually GNU tail is there by default in Solaris 11). Solaris sysadmins often make it harder for their users because they leave the install at the very bare-bone install while GNU tools for Solaris are actually these days available directly from Oracle or in some cases part of default install. No reason not to make it part of your install. No reason to go to 'unofficial' repos. See link. Commented Jul 30, 2013 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .