Modify archive.sh to work with DreamHost


(LimaEasy) #1

When running the cron job on DreamHost to execute the archive.sh I’m getting the following error message:

php binary not found. Make sure php5 or php exists in PATH.

What I have understood so far is, that I have to modify the archive.sh to point to the PHP interpreter (in my case PHP is located in /usr/local/bin/php). Where do I modify the script? Or better could somebody please post a modified archive.sh

Thanks


(vipsoft) #2

If you edit archive.sh, your changes will be lost when you update Piwik (and the file is overwritten).

Just add /usr/local/bin to your PATH. “echo $PATH”. Then, at the top of your crontab:

PATH=/your-existing-path-from-above:/usr/local/bin

(LimaEasy) #3

I’ve never used the SSH access to set-up my cron (and I’m not very familiar with it either). In DreamHost you can set up the cron jobs in the Panel. Thats the reason I thought my only way out would be to modify the archive.sh. If this file gets updated with every new release it’s out of the question to modify it.

To allow me a good start with creating the cron job with SSH could you please give me the “whole thing” (meaning the cron job) considering:

The location of the Piwik install: /home/myuser/mysite/statistics/misc/cron/archive.sh
The PHP being located in: /usr/local/bin/php

Thank you!


(LimaEasy) #4

Ok, I’ve set up a cron job that looks like this (for testing purposes set to 10 minutes):

MAILTO=mail@mysite.com
PATH=/usr/local/bin/php:/usr/local/bin
*/10 * * * * /home/myuser/mysite/statistics/misc/cron/archive.sh

The result is again: php binary not found. Make sure php5 or php exists in PATH.


#5

You can also do this;

Comment these lines

#for TEST_PHP_BIN in php; do

if which $TEST_PHP_BIN >/dev/null 2>/dev/null; then

PHP_BIN=which $TEST_PHP_BIN

break

fi

#done

And add this line
#Your PHP path
PHP_BIN=/usr/local/zend/bin/php


#6

Dreamhost cron does not execute with a normal environment. This means you cannot use bare commands. You just need to add this line before the cron: /usr/local/php5/bin/php

So in their Control Panel, edit your cron so the entire line looks like this: /usr/local/php5/bin/php /home/USERNAME/PIWIKFOLDER/misc/cron/archive.sh

For more DH cron information, click here: http://wiki.dreamhost.com/Cron#Executing_a_PHP_script_with_Crontab_through_the_control_panel


(vipsoft) #7

That won’t work rhotog because archive.sh is a bash shell script.

Try setting your path at the top of the crontab, e.g.,


PATH=/usr/local/php5/bin:$PATH


(jekko) #8

Anthon

We are hosted by 1and1 and have a problem getting the script to run i have tried modifying the script as above adding the path to the cron etc. nothing seems to work, in the end i gave up i just don’t have enough knowledge to implement archiving. still loving piwik tho …ty.

(1and1 use php4 by default, we use the .htaccess trick for php5)
php5 is located at: /usr/bin/php5

we get the following output from the script

/bin/sh: -
: invalid option

We have spoken to our host about it and their reply is below.

Also, i did notice a forum post where a php script had been used as the archiving script but it had stopped working since 1.4. It would be nice if there was an alternative php script for archiving. There must be a lot of users on shared hosts that can not get this to work. http://forum.piwik.org/read.php?2,77295


#9

You’re right, thanks Anthon! I thought the script was running fine because I wasn’t getting an error in the Cron emails, but it turns out the script wasn’t being processed. I spent some time with Dreamhost’s Customer Service and was able to get it running by doing the following steps:

  1. Log in to the account using SSH
  2. Enter this into the command line: “echo $PATH”
  3. This spit out a bunch of path variables. Copy this data.
  4. Go to the Cron Job and enter the PATH data before the cron. It should look something like this:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/games /bin/bash /home/USERNAME/PIWIKFOLDER/misc/cron/archive.sh

Note that this command was entered using the Cron Job manager in their Control Panel, not the SSH command line.

When the script ran, I was also getting the following error:


suhosin[28236]: ALERT - script tried to increase memory_limit to 134217728 bytes which is above the allowed value (attacker '150.70.75.38', file '/home/USERNAME/PIWIKFOLDER/core/Piwik.php', line 881)

I changed the minimum_memory_limit in config.ini to be 85MB and the script ran without errors. I’m on a VPS, so the memory limit might be lower for standard hosting packages. Now my Piwik dashboard is running very fast! :slight_smile:

I hope this helps save someone else the time it took to troubleshoot.

Edit: Updated the cron command for accuracy and included better instructions


(Thierry) #10

Thank you rhotog for the explanations.

It has been very helpful. :slight_smile: