Linux Error Log Tail results in the Error: Binary file (standard input) matches

I ran across a rather interesting bug the other day.  The problem was that I was unable to tail the error logs on our web servers.  I simply got the following output when trying to tail a log:

$ sudo tail -f /var/log/httpd/*
 Binary file (standard input) matches

These types of errors can always drive me a little nuts… because the output really gives me very little info into what is actually going on.

In this case however the issue was around our compression.  For this particular web pool we are doing a lot of verbose logging to help collect data and optimize performance.  Once the log is finished for the day it is compressed.  I was unable to perform the tail command above because the compressed files located in the same folder could not be tailed.

In essence there is our standard log file “error_log.log” as well as the daily backups that are gzipped due to file size.  These files are named such as error_log.1.gz, error_log.2.gz and so forth.

When I performed the tail command using * as the name of the file it attempted to tail all of the files.  Including the GZipped files.  This caused the error: “Binary file (standard input) matches” and caused tail to crash.

To get around this you really have two options.  1 is to disable gzipping (which I don’t advise due to space).  The 2nd is be more specific about the files you want to tail.  If you know the full path of the file you want to tail, then include that file directly.  If you don’t know the exact file then you can still get around this error by specifying the file extension.

$ sudo tail -f /var/log/httpd/*.log

The above command will still enable you to grab all of the log files regardless of name, yet will still keep you away from the gzipped files that case the error: “Binary file (standard input) matches”

Posted in , and tagged , .