Problem: Want to generate GoAccess report file on website every day --
sudo cat /var/log/apache2/access.log | goaccess > /var/www/goaccess/index.html
above command although work in a normal case ( manually generate report in/var/www/goaccess/index.html ), for regular task like generate HTML reports in cron every day is not working -- above command put in cron file is not work and the file name is not in date format.
Solution: first ensure we let GoAccess know the datetime format setting for the report:
sudo vi ~/.goaccessrc
edit ~/.goaccessrc and fill with below code:
time-format %T date-format %d/%b/%Y log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
And then in the crontab file change GoAccess command with
sudo goaccess -p ~/.goaccessrc /var/log/apache2/access.log -a -o /var/www/goaccess/`date +\%Y\%m\%d\%H\%M\%S`.html
Remember set up the time expression, mine one is running at 5:55 am
55 5 * * * sudo goaccess -p ~/.goaccessrc /var/log/apache2/access.log -a -o /var/www/goaccess/`date +\%Y\%m\%d\%H\%M\%S`.html
the filename format will be like below image
