bashgoaccess

Goaccess Process Multiple Logs


I have a directory with log files. I want to process the last 13 of them (past quarter). I can't use a wildcard using Goaccess because I don't want to include all of them, just the last 13 generated weeks' worth.

I have an array of the filenames of those last 13 files, but I don't know the syntax for the Goaccess command to include those files. I can't find any reference as to how to do this, as all notes I've seen refer to using a wildcard. I don't want to start copying and moving files around. There should be a way of doing this in the command line with multiple filenames which I can generate just fine.

How can I use a multiple logname input syntax in Goaccess?

Something like:

/usr/local/bin/goaccess -p /users/rich/things/goaccess.conf log1.log log2.log log3.log -o qreport.html

Solution

  • MULTIPLE LOG FILES

    There are several ways to parse multiple logs with GoAccess. The simplest is to pass multiple log files to the command line:

    goaccess access.log access.log.1

    goaccess-custom-logs

    In your case, you need to process only the last three generated file so you can get the last three file using ls. The final command will become

    /usr/local/bin/goaccess -p /users/rich/things/goaccess.conf  $(ls -t log* | head -3 | tr '\r\n' ' ') -o qreport.html
    

    This will process the last three files that is started with log