Search code examples
filenamessolarisfile-descriptortail

Tail command - follow by name on Solaris


Is there a way to tail a file by name on Solaris 10? Equivalent to:

tail --follow=name

Manual for tail on solaris shows no such option. Only -f is included and it looks like it follows a file by descriptor.


Solution

  • According to the GNU tail manual, --follows is the same as -f:

    -f, --follow[={name|descriptor}]
        output appended data as the file grows;
    
        an absent option argument means 'descriptor'
    

    A -f option is found in the POSIX description of tail. However, the --follows option (which accepts an option value) is not in POSIX. The GNU manual goes on to describe the --follow option where it differs from -f:

    With --follow (-f), tail defaults to following the file descriptor, which means that even if a tail'ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not the file descriptor (e.g., log rotation). Use --follow=name in that case. That causes tail to track the named file in a way that accommodates renaming, removal and creation.

    That is, --follow provides for reopening the file if the actual file was renamed. POSIX does not appear to address this use case.

    There is no direct equivalent in Solaris's differences from POSIX (compare /usr/bin/tail and /usr/xpg4/bin/tail in manual).

    GNU tail is part of the coreutils package. You may already have it installed on Solaris 10, in /opt/sfw/bin/tail. For instance, pkginfo shows it on my Solaris 10 machine as SFWcoreu.