Effettuo una rotazione dei log di accesso del server apache2 mensilmente, questo per poter disporre dei log per le statistiche.
Mentre per awstats, lo faccio partire un po' prima di mezzanotte e quindi ho le statistiche complete, al limite mancano 5 minuti.
Awstats mette il suo script nel cron.daily, lo script è il seguente:
Codice: Seleziona tutto
#!/bin/sh
# /etc/cron.daily/webalizer: Webalizer daily maintenance script
# This script was originally written by
# Remco van de Meent <remco@debian.org>
# and now, all rewrited by Jose Carlos Medeiros <jose@psabs.com.br>
# This script just run webalizer against all .conf files in /etc/webalizer directory
WEBALIZER=/usr/bin/webalizer
WEBALIZER_CONFDIR=/etc/webalizer
[ -x ${WEBALIZER} ] || exit 0;
[ -d ${WEBALIZER_CONFDIR} ] || exit 0;
for i in ${WEBALIZER_CONFDIR}/*.conf; do
# exists ?
[ -f $i ] || continue;
# run agains a rotated or normal logfile
LOGFILE=`awk '$1 ~ /^LogFile$/ {print $2}' $i`;
# empty ?
[ -s "${LOGFILE}" ] || continue;
# readable ?
[ -r "${LOGFILE}" ] || continue;
# there was a output ?
OUTDIR=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`;
# exists something ?
[ "${OUTDIR}" != "" ] || continue;
# its a directory ?
[ -d ${OUTDIR} ] || continue;
# its writable ?
[ -w ${OUTDIR} ] || continue;
# Run Really quietly, exit with status code if !0
${WEBALIZER} -c ${i} -Q || continue;
RET=$?;
# Non rotated log file
NLOGFILE=`awk '$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,""); print $2}' $i`;
# check current log, if last log is a rotated logfile
if [ "${LOGFILE}" != "${NLOGFILE}" ]; then
# empty ?
[ -s "${NLOGFILE}" ] || continue;
# readable ?
[ -r "${NLOGFILE}" ] || continue;
${WEBALIZER} -c ${i} -Q ${NLOGFILE};
RET=$?;
fi;
done;
# exit with webalizer's exit code
exit $RET;
Codice: Seleziona tutto
sam@locale:/etc$ cat crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
Codice: Seleziona tutto
# /etc/cron.d/php@PHP_VERSION@: crontab fragment for PHP
# This purges session files in session.save_path older than X,
# where X is defined in seconds as the largest value of
# session.gc_maxlifetime from all your SAPI php.ini files
# or 24 minutes if not defined. The script triggers only
# when session.save_handler=files.
#
# WARNING: The scripts tries hard to honour all relevant
# session PHP options, but if you do something unusual
# you have to disable this script and take care of your
# sessions yourself.
# Look for update and purge old sessions every 30 minutes
00 */4 * * * root [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh
Qualche suggerimento ?
Al momento ho risolto così, tanto webalizer ci mette un attimo a fare le statistiche, quindi ho rimosso webalizer da /etc/cron.daily e copiato in una cartella /home/utente dopo ho editato crontab -e e configurato che parta alle 23,59, per essere certo che sia in anticipo sul logrotate. A quel'ora awstats di solito ha finito le sue statistiche, partendo alle 23,50.