Problems running AWStats from cron

apps

#1

Hey all…

I’ve been in the process of setting up AWStats on my account, and everything has gone fine except for the last step - setting up a cron job to run the reports automatically. This seems to be beyond my abilities to get right.

Here’s what I did. First, I followed the instructions in the excellent “Newbie’s desperate cry” thread (thanks Skybly!). This got everything bootstrapped nicely, with AWStats living in my ~/awstats directory, and a data directory set up in the first domain I configured for stats (jasonlefkowitz.net) called “mystats” into which AWStats would dump the report files.

I then added this line to my crontab:

5 3 * * * perl /home/<myusername>/awstats/tools/awstats_buildstaticpages.pl -config=jasonlefkowitz.net -update -awstatsprog=/home/<myusername>/awstats/awstats.pl -dir=/home/<myusername>/jasonlefkowitz.net/mystats/… which should run AWStats at 3:05 AM every day on the jasonlefkowitz.net logs, and drop the results into that mystats/ directory. If I run this command from the prompt, rather than from cron, that is in fact exactly what happens.

But if I leave it to cron to execute, nothing seems to happen – the reports don’t get updated. The weird part is, I don’t get any e-mail warning me of a cron error, either, which I would normally get if there was a syntax error somewhere in the crontab (or something else really wrong, like a required module not being present/found in @INC/etc.). It just seems to “fail” silently.

I checked the permissions on the .pl files in the awstats/ and awstats/tools/ directories, and they’re all good to execute (like I said, they run fine from the prompt). So it doesn’t seem to be that either.

Can anyone give me any ideas on where to look next? I know there must be a way to make this work, but I am sure running out of ideas on how to find it.

Thanks!

– Jason Lefkowitz


#2

Yep, it shows up when I do crontab -l (and all on one line – I just broke it up in my post to keep the post from requiring lots of horizontal scrolling).

I know that cron is executing because I have another job scheduled in there (the MT_Rebuild plug-in that automatically rebuilds Movable Type blogs), and it runs fine every hour. It’s just this job that doesn’t seem to be running.


#3

Since I have several sites I run awstats on, I created a script (which is what I schedule to execute with cron).

my crontab entry is
00 2 * * * /home/eastend/awupdate

Also, in order to get email output from cron, I had to put this at the top of my crontab file:
MAILTO="dave@torbie.com"

and the awupdate shell script is:
/bin/date
cd /home/eastend/my.com/cgi-bin
/usr/local/bin/perl /home/eastend/my.com/cgi-bin/awstats.pl -config=torbie -update
/bin/date
/usr/local/bin/perl /home/eastend/my.com/cgi-bin/awstats.pl -config=nceastenders -update

in the awstats config file, I updated the logfile entry with:
LogFile="/home/eastend/logs/my.com/http/access.log.%YYYY-24-%MM-24-Ý-24"

Dave - Torbie Arts Photography


#4

Dave,

this is interesting. I tried running AWStats using your command syntax:

/usr/local/bin/perl /home/<username>/awstats/awstats.pl -config=jasonlefkowitz.net -update from the shell prompt, and it seemed to run fine, giving the following report:

Phase 1 : First bypass old records, searching new record... Direct access to last remembered record is out of file. So searching it from beginning of log file... Phase 2 : Now process new records (Flush history on disk after 20000 hosts)... Jumped lines in file: 0 Parsed lines in file: 831 Found 0 dropped records, Found 0 corrupted records, Found 0 old records, Found 831 new qualified records. BUT, the static pages in the reports directory weren’t updated.

Maybe this is the same thing that’s happening to me when cron does the update? This is a different command than I was using (I was calling awstats_buildstaticpages.pl) – is this supposed to update the static pages, or does it just update AWStats’ internal database?

Maybe I need a shell script that runs both of these commands, and have cron call that? Does it matter that my awstats.pl is outside the web root of my site? If only the AWStats documentation was better… (sigh)

Thanks for your help!

– Jason


#5

The doc could definitely be better! The way I read it, you need to run “awstats.pl -update” to update it’s database first. Then you could run “awstats_buildstaticpages.pl” to create the static stats page. I’ve opted instead to use the dynamic reporting page by running the cgi from the web:

http://www.mysite.com/cgi-bin/awstats.pl?config=mysite

Dave - Torbie Arts Photography


#6

You don’t need to run the update command before running awstats_buildstaticpages.pl - the “update” parameter to that script will cause the statistics to be updated before building the pages. I just have that one line in my crontab and it works fine:

0 4 * * * perl /home//awstats/tools/awstats_buildstaticpages.pl -config=
-update -awstatsprog=/home//awstats/awstats.pl -dir=/home/
//awstats/

So, I don’t know why it doesn’t work for you unfortunately, but the command shouldn’t the problem…


Pointy-Ears.net


#7

Hmm… veeeeery interesting.

Maybe it is a permissions thing? Some file that needs its perms tweaked, or a directory that needs chmod-ing? Did you do anything special permissions/ownership-wise when setting things up since your AWStats files were outside the web root? (I ask because the docs all seem to assume you’re going to install to web root/cgi-bin…)

– Jason