r/sysadmin • • Mar 30 '15

Linux Stop using tail -f (mostly)

http://www.brianstorti.com/stop-using-tail/
89 Upvotes

23 comments sorted by

View all comments

7

u/jftuga Mar 31 '15

I like this tip and can't wait to try it.

I also like to use:

tail -0f file.log

This starts the 'tail -f' process without seeing any of the previous log entries.

1

u/[deleted] Mar 31 '15

Wow. Today I learned you can tailf multiple logs and only content at the end of a file. Neat. One thing though, it looks like that doesn't work for multiple files unless I'm doing something incorrectly here:

[root@controller ~]# tail -0f  /var/log/httpd/access_log /var/log/messages
tail: invalid option -- 0
Try `tail --help' for more  information.

1

u/jftuga Apr 02 '15

On your version of tail you will have to use -1f instead of -0f. This means you will only see the last line in the log file instead of none.

2

u/[deleted] Apr 02 '15

Hmm, that didn't seem to do it, but the following did:

tail -c 0 -f     
/var/log/httpd/access_log   
/var/log/httpd/error_log

printf "TEST2\nTEST3" >> access_log && printf "TEST2\nTEST3" >> error_log

 ==> /var/log/httpd/access_log       
<==
TEST2
TEST3
==> /var/log/httpd/error_log <==
TEST2
TEST3