1

Topic: Awstats Not Running From CRON

Seems that my setup is fine, except that awstats does not seem to be updating.
Extract from the /var/log/syslog:
Mar  7 14:10:01 mail /USR/SBIN/CRON[10129]: (www-data) CMD ([ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh)
Mar  7 14:10:01 mail /USR/SBIN/CRON[10127]: (CRON) error (grandchild #10129 failed with exit status 1)
Mar  7 14:17:01 mail /USR/SBIN/CRON[10135]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar  7 14:20:01 mail /USR/SBIN/CRON[10140]: (www-data) CMD ([ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh)
Mar  7 14:20:01 mail /USR/SBIN/CRON[10138]: (CRON) error (grandchild #10140 failed with exit status 1)
Mar  7 14:30:01 mail /USR/SBIN/CRON[10146]: (www-data) CMD ([ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh)
Mar  7 14:30:01 mail /USR/SBIN/CRON[10144]: (CRON) error (grandchild #10146 failed with exit status 1)
Mar  7 14:39:01 mail /USR/SBIN/CRON[10157]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm)
Mar  7 14:40:01 mail /USR/SBIN/CRON[10167]: (www-data) CMD ([ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh)
Mar  7 14:40:01 mail /USR/SBIN/CRON[10165]: (CRON) error (grandchild #10167 failed with exit status 1)
Mar  7 14:50:01 mail /USR/SBIN/CRON[10214]: (www-data) CMD ([ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh)
Mar  7 14:50:01 mail /USR/SBIN/CRON[10212]: (CRON) error (grandchild #10214 failed with exit status 1)

Entry in the /etc/cron,d/awstats file:
root@mail:/etc/cron.d# cat awstats
*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh
# Generate static reports:
10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh

Regards,
Larry

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Awstats Not Running From CRON

Re-bump.

3

Re: Awstats Not Running From CRON

iRedMail doesn't have "/usr/share/awstats/tools/update.sh" by default, did you create it yourself? If so, you have to troubleshoot it yourself.

4

Re: Awstats Not Running From CRON

ZhangHuangbin wrote:

iRedMail doesn't have "/usr/share/awstats/tools/update.sh" by default, did you create it yourself? If so, you have to troubleshoot it yourself.

ARGH.  Ok.  I did not create it but it is there.  hmm..
#!/bin/sh
##
## update.sh, written by Sergey B Kirpichev <skirpichev@gmail.com>
##
## Update AWStats data for all configs, awstats.*.conf (Debian specific)
##
set -e
DEFAULT=/etc/default/awstats
AWSTATS=/usr/lib/cgi-bin/awstats.pl
ERRFILE=`mktemp --tmpdir awstats.XXXXXXXXXX`
trap 'rm -f $ERRFILE' INT QUIT TERM EXIT
[ -f $AWSTATS ] || exit 1
# Set defaults.
AWSTATS_NICE=10
[ ! -r "$DEFAULT" ] || . "$DEFAULT"
cd /etc/awstats
for c in awstats \
         `/bin/ls -1 awstats.*.conf 2>/dev/null | \
          /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'`
do
  if ! nice -n $AWSTATS_NICE $AWSTATS \
          -config=$c \
          -update >$ERRFILE 2>&1
  then
    cat $ERRFILE >&2 # an error occurred
  fi
done


Maybe I need to talk with the Ubuntu maintainers of AWstat, eh?   More back later when I get smarter.

5

Re: Awstats Not Running From CRON

The problem is that the package maintained for Ubuntu has three scripts in the Awstats tools directory that generate the initial statistics.  The syslog had the error line:
Mar 27 17:50:01 mail CRON[2997]: (www-data) CMD ([ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh)
Mar 27 17:50:01 mail CRON[2995]: (CRON) error (grandchild #2997 failed with exit status 1)

There was a post, by “Luke” in  Italian, at http://osdir.com/ml/debian-italian/2010 … 00232.html which, translated by Google, reads:
I solved it. The problem is access to the apache log file by awstats.
I added the user www-data to the adm group is the group that they belong to the files in / var/log/apache2.

So, added www-data to the group adm.
root@mail:/var/log/apache2# ls -al
total 2620
drwxr-x---  2 root adm     4096 2011-03-27 06:25 .
drwxr-xr-x 12 root root    4096 2011-03-27 10:02 ..
-rw-r-----  1 root adm        0 2011-03-27 06:25 access.log
-rw-r-----  1 root adm      598 2011-03-27 10:02 error.log   
-rw-r--r--  1 root root       0 2011-03-17 18:45 other_vhosts_access.log
-rw-r-----  1 root adm        0 2011-03-27 06:25 rewrite.log
-rw-r-----  1 root adm   200154 2011-03-27 17:45 ssl_access.log

root@mail:/var/log/apache2# cat /etc/group |grep adm
adm:x:4:ldgrim
lpadmin:x:107:ldgrim
admin:x:109:ldgrim
iredadmin:x:1003:

root@mail:/var/log/apache2# usermod -a -G adm www-data
root@mail:/var/log/apache2# cat /etc/group |grep adm
adm:x:4:ldgrim,www-data
lpadmin:x:107:ldgrim
admin:x:109:ldgrim
iredadmin:x:1003:

root@mail:/var/log/apache2#
Also, had to make a symbolic link from the awstats.pl file to jibe with the paths in the three shell scripts. 
ln -s /usr/lib/cgi-bin/awstats/awstats.pl /usr/lib/cgi-bin/awstats.pl
And finally, awstats is updating.