It’s too easy not to!

If you haven’t already:

# apt install goaccess

Then, create /etc/cron.daily/apache_report with the following contents

#!/bin/bash
goaccess /var/log/apache2/other_vhosts_access.log --log-format=VCOMBINED -o report.html
gzip report.html
echo "Report" | mail -s "Apache Report" -A report.html.gz you@yourdomain.com

Remember to change the email address to your email address

tips

Instead of waiting a day to find out if the script is working correctly, you can copy apache_report to /etc/cron.hourly and then cd into it and run:

# run-parts .

If all went well, you should have a new email with a nicely formatted html report.

Remember to delete the script from /etc/cron.hourly or you’ll have a full inbox!

Also, I’m assuming that you’re using virtual hosts in Apache. If not, you can reference access.log instead of other_vhosts_access.log