Cron job for generate Go Access report not working

拈花ヽ惹草 提交于 2021-01-29 18:29:40

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/64002655/cron-job-for-generate-go-access-report-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!