Cron mail errors in /usr/share/awstats/tools/update.sh for sites without traffic (with workaround)
If a website has no accesses then the link to yesterday-access.log
points to an existing file, leading to a Permission denied / No such file or directory
error.
root
will be flooded with email (one every 10 minutes) containing multiple repetitions of:
Error while processing /etc/awstats/awstats.example.org.conf
Create/Update database for config "/etc/awstats/awstats.example.org.conf" by AWStats version 7.0 (build 1.971)
>From data in log file "/var/log/ispconfig/httpd/example.org/yesterday-access.log"...
Error: Couldn't open server log file "/var/log/ispconfig/httpd/example.org/yesterday-access.log" : Permission denied
Setup ('/etc/awstats/awstats.example.org.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
Or:
Error while processing /etc/awstats/awstats.example.org.conf
Create/Update database for config "/etc/awstats/awstats.example.org.conf" by AWStats version 7.0 (build 1.971)
>From data in log file "/var/log/ispconfig/httpd/example.org/yesterday-access.log"...
Error: Couldn't open server log file "/var/log/ispconfig/httpd/example.org/yesterday-access.log" : No such file or directory
Setup ('/etc/awstats/awstats.example.org.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
This is especially annoying if there's an alias to send root
mail to some remote email address or ticket system.
My workaround is the following: make a daily request to every website using CURL.
Create a file named cat /etc/cron.daily/awstat-fix
:
#!/bin/bash
grep ServerName /etc/apache2/sites-enabled/* | sed "s/^.*ServerName //g" | xargs -I {} curl -s http://127.0.0.1/ -H "Host: {}" -o /dev/null
Then set the execution bit:
chmod +x /etc/cron.daily/awstat-fix
All done! It's something similar to the internal request done by apache to it's server-status.
Is this somehow useful and can be integrated upstream?
Are there better ways (than completely silencing the cron script and loosing all the useful error messages that could arise)?
Thanks, Francesco