3

In my root crontab (sudo crontab -e) I have this job to generate Go Access log reports:

* * * * * goaccess /var/log/nginx/access.log -o /home/me/some/path/report.html

It works just fine. I also have this job to generate a report that spans multiple days:

* * * * * sudo zcat -f /var/log/nginx/access.log* | goaccess -o /home/me/some/path/bigger_report.html

Cron says it runs but it doesn't actually seem to run. I've looked around and tried a bunch of things (including following the list here - https://stackoverflow.com/a/22744360/3761310) but still can't get this job to run. If I run the command myself it generates the file as expected. I also tried just the part before the pipe, outputting into a txt file and that worked. So I suspect it's some interaction with Go Access.

When I enabled cron logging, this is what it says when that job runs:

(root) CMD (sudo zcat -f /var/log/nginx/access.log* | goaccess -o /home/me/some/path/bigger_report.html)

Any pointers? Thanks!

3
  • this may help askubuntu.com/questions/173924/…
    – 0xedb
    Sep 22, 2020 at 3:28
  • @theBashShell thanks for the response. I actually started my night there, which is why I'm putting these commands in sudo crontab -e. Am I missing something from that post?
    – DukeSilver
    Sep 22, 2020 at 3:33
  • You claim it's specific to goaccess and/or zcat, is that actually the case? What did you observe to conclude that "it doesn't actually seem to run"? When and why are you using sudo? Is that relevant to this problem even? Sep 22, 2020 at 19:43

1 Answer 1

8

You need to let goaccess know you are piping data using the -. e.g.,

* * * * * sudo zcat -f /var/log/nginx/access.log* | goaccess - -o /home/me/some/path/bigger_report.html
3
  • 1
    thanks, that seems to have set it straight. I didn't know that was the case, since the command worked fine when run manually, but for anyone in the future, the relevant doc seems to be here under "Multiple Log Files" - goaccess.io/man#examples
    – DukeSilver
    Sep 22, 2020 at 19:53
  • 1
    This saved the day. @DukeSilver of course, but why spend 10 minutes on reading documentation instead of trying out random things for 2 hours to fix the issue? I always prefer the later.
    – cherouvim
    Jun 15, 2021 at 7:12
  • same here. It's so odd that it works without this when on the command line and not as a cron job. I'd love to understand why that is.
    – kevincw01
    Jun 10 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.