Tail command - follow by name on Solaris

1.1k views Asked by At

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.

4

There are 4 answers

3
Thomas Dickey On BEST ANSWER

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.

0
jim mcnamara On

Solaris does not have --follow as you see.

The workaround is redirection:

tail -f inputfile > filewritten_by_tail
0
jlliagre On

Your best bet is to install GNU find either from source or some freeware repository.

If you really want to stick with Solaris 10 bundled find, you'll need to wrap it with a custom monitoring program that will restart it should the target file is renewed.

0
Joe_Garbagio On

Works like a charm on solaris 11!

/usr/bin/gtail -F