GoDaddy, Cron Jobs, Archiving & Query Strings

First, some praise … THANK YOU! You folks have put together a fantastic stats package. Have been using GA (The Gorg’s Analytics app) for many years, but have become leary of them and their ‘practices’ over the last year.

Have experimented with a few different stats options and we finally settled on Piwik 1.8.

The installation went smooth as silk - 8 days ago when we first launched our website; we’ve been regularly accessing the stats as myself and my partner suffer from stats OCD (I’ve been involved in SEO/SEM for almost a decade now, and my partner is enjoying learning all about metrics). We love it!

OK, now down to business…

Am fully cognizant of the fact that each time we log in, the reports get generated dynamically. However, the last two days, logging in reminds me of the ‘good ole days’ of dial-up: submit a form, go make coffee, and come back to the last of the dashboard rendering.

We’re running on GoDaddy’s Deluxe shared hosting (and looking at other options as we grow our business). I understand the option available to us would be Web Crons to get the hourly archiving going after having read several FAQs and forum threads including…

How to Set up Auto-Archiving of Your Reports
http://piwik.org/setup-auto-archiving/

Godaddy CronJob & archive.sh
301 Moved Permanently
(** as an aside, why use archive.sh rather than archive.php? Older/legacy implementation? **)

Still having issues
http://forum.piwik.org/read.php?2,82487,82677

etc.

… but I wasn’t able to nail down an answer specific to the following.

Here’s our dilemma with archiving on GoDaddy.

GoDaddy limits what you can do with cron jobs via their web hosting/cron job interface. This includes properly processing calls which include query-strings which always end in error messages being emailed back (past experience on having attempted to do so on a few different occasions). It’s been my experience that, if I create a very simple, one-line php file which runs the url requiring a query string within an include I can bypass, or hack, this limitation.

Here’s my concern - if we do the same w/Piwik and run the following

http://mysite.com/piwik-folder/misc/cron/archive.php?&token_auth=[put-your-token-here]

… in a one line php file using include(), will this have any negative impact or bearing on our stats? Has anyone else attempted to do the same? If so, what do we need to look out for? Is there another suggestion (aside from moving to another hosting platform)?

Rather than impact our stats, corrupt our data or screw up the report archiving, thought I’d seek out some informed, educated answers here.

We can restrain ourselves with respect to logging in and restrict ourselves to accessing stats for the wee hours, but I’d rather get the archiving process via cron job handled ASAP as, happily, our traffic is beginning to increase quite a bit.

Look forward to any and all responses, and, once again, thank you! Great job to all involved!
Once our business begins to really take off, you’ll likely be seeing some proper thank$.

EDIT: another idea just crossed my mind - using a header redirect - ie: header(location: [put-url-here]). Any thoughts on impact/issues?

OK… set the report generator to 3600 and it takes forever to login now. So decided to force the archiving to work.

Well header redirect, include, wget, and curl won’t work… followed a third-party instructional on attributing vars to cron jobs on GoDaddy as GD themselves don’t provide support for third party scripts/apps (had to laugh), and setting up web cron as follows doesn’t work…

/web/cgi-bin/php5 “$HOME/html/misc/cron/archive.php” token_auth=[put-token-here]*

… and neither does …

/web/cgi-bin/php5 “$HOME/html/misc/cron/archive.php” --url=https://www.mysite.com/piwik/ token_auth=[put-token-here]*

… and neither does …

/web/cgi-bin/php5 “$HOME/html/misc/cron/archive.php” url=https://www.mysite.com/piwik/ token_auth=[put-token-here]*

Ended up hacking the archive.php file and hard-coding both the url and the token_auth vars in initPiwikHost() (commented out the whole function and simply hardcoded $this->piwikUrl) and initCheckCli() line 603 respectively

Got a little farther… but ended up with the following:

INIT
Querying Piwik API at: [-url-]/index.php
Running as Super User: [-myself-]
ERROR: Got invalid response from API request: [-url-]/index.php?module=API&method=API.getDefaultMetricTranslations&format=php&trigger=archivephp. Response was 'curl_exec: couldn’t connect to host’
ERROR: The Piwik URL [-url-]/index.php does not seem to be pointing to a Piwik server. Response was ‘’.
Fatal error: The Piwik URL [-url-]/index.php does not seem to be pointing to a Piwik server. Response was ‘’. in [/path/to/piwik]/misc/cron/archive.php on line 555

Nothing in the aforementioned output dump has been removed with the exception of the url and paths which have been replaced; [-url-] is the domain & path on which piwik resides - it’s on the same domain/server as our own site; but we did manage to authenticate via hard-coded token. Seems GD doesn’t like curl requests from its server back to the same server. And, as you can see, the response was an empty string.

While I can continue tearing the code apart and try to make it work, is there REALLY no one else who’s made this work on GoDaddy without hacking the s**t out of Piwik and wasting even more time?

EDIT: both Piwik and our site run off the same domain over https

Well… FINALLY got it to work… here’s how:

Don’t…
[ol]
[li] Rely on GD support or their help, forums or any other of their ‘documentation’
[/li][li] Use their default PHP or PHP5 cron job strings ie: /web/cgi-bin/php or /web/cgi-bin/php5
[/li][li] Wrap the URL in quotes (take note below)
[/li][li] Bother wasting time trying to hack Piwik
[/li][/ol]

Do…
[ol]
[li] Ensure you set archive.php to 755 permissions
[/li][li] Insert following into cron job ‘browse’ line:
[/li]/usr/bin/curl http(s)://www.mysite.com/path/to/piwik/misc/cron/archive.php?token_auth=[insert-token]
[li] Replace [insert-token] with your token_auth key
[/li][/ol]

Special thanks to - Gary at WP-O-Matic

Nick thanks for this share. I had given up on making it work with Godaddy. (tu)

thanks for share

Adrian,

Where there’s a will, there’s a way! >:D<
Glad to be of help.

filesworld,

if (open source == sharing) {$everyone=“benefits”;} else {$nobody=“wins”;}

And the cron job continues to work perfectly.

Good luck! :wink:

Thanks for posting the solution!

If anybody has problem on making cron job to work, or your hosting disabled/limited cron job usage, easycron.com could be an good alternative to Cron under Linux. We offers cron job service with up to 1200 seconds timeout which is enough for long time script running.

Disclaimer: I work in EasyCron.