I am experiencing problems with running the Piwik cron job.
If I run archive.sh via SSH, everything works fine and I get the following output:
Starting Piwik reports archiving...
Archiving period = day for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2011-08-10">8514</result>
…
<result date="2011-09-30">917</result>
</results>
Archiving period = week for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2010-10-04 to 2010-10-10">6446</result>
…
<result date="2011-09-26 to 2011-10-02">10894</result>
</results>
Archiving period = month for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2007-06" />
…
<result date="2011-09">90591</result>
</results>
Archiving period = year for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2001" />
…
<result date="2011">467676</result>
</results>
Archiving for idsite = 1 done!
Reports archiving finished.
---------------------------
Starting Scheduled tasks...
task,output
Piwik_CoreAdminHome.optimizeArchiveTable,Time elapsed: 0.543s
Piwik_PrivacyManager.deleteLogTables,Time elapsed: 0.000s
Finished Scheduled tasks.
After that, I can see the updated data in the Piwik interface.
If I run archive.sh as cron job, the output looks very similar – except for “No data available” at the end.
It makes no difference if I call the cron job as root or as a privileged user.
The main problem is: If archive.sh is run as cron job, no new data is displayed in Piwik’s interface.
Archiving period = day for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2011-08-09">9794</result>
…
<result date="2011-09-29">2370</result>
</results>
Archiving period = week for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2010-10-04 to 2010-10-10">6446</result>
…
<result date="2011-09-26 to 2011-10-02">9966</result>
</results>
Archiving period = month for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2007-06" />
…
<result date="2011-09">89663</result>
</results>
Archiving period = year for idsite = 1...
<?xml version="1.0" encoding="utf-8" ?>
<results>
<result date="2001" />
…
<result date="2011">466748</result>
</results>
Archiving for idsite = 1 done!
Reports archiving finished.
---------------------------
Starting Scheduled tasks...
No data available
Finished Scheduled tasks.
Have you tried configuring your environment variables like .bash_profile?
Maybe the crontab didn´t recognize the variable PHP_HOME or PHP_BIN.
You have to configure your .bash_profile like this:
Or in your crontab put variable PATH into the crontab, like this:
PATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/prd1bea/bin:/app/prd1bea/php5.3.8/bin
Let me know if these solutions it´s worked for you.
My apologies wmnnd, when I was talking about the path I was referring to what ramilani12 suggested to do.
In our archive.sh script we had to comment out the top lines and add the PHP_BIN path.
#for TEST_PHP_BIN in php5 php php-cli php-cgi; do
# if which $TEST_PHP_BIN >/dev/null 2>/dev/null; then
# PHP_BIN=`which $TEST_PHP_BIN`
# break
# fi
#done
#if test -z $PHP_BIN; then
# echo "php binary not found. Make sure php5 or php exists in
#PATH." >&2
# exit 1
#fi
PHP_BIN=/opt/lampp/bin/php
Though I believe if you had to do this you would have been given an error when trying to run the archive.sh.
We also had to enter:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/lampp/bin
in the crontab