Problem with archive script



I am trying to setup a cron job to do the archiving, this is the cron details:

But when it runs I just get the following in an e mail:

Usage: php [options] [-f] [–] [args…]
php [options] -r [–] [args…]
php [options] [-B <begin_code>] -R [-E <end_code>] [–] [args…]
php [options] [-B <begin_code>] -F [-E <end_code>] [–] [args…]
php [options] – [args…]
php [options] -a

-a Run interactively
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value ‘bar’
-e Generate extended information for debugger/profiler
-f Parse and execute .
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r Run PHP without using script tags <?..?>
-B <begin_code> Run PHP <begin_code> before processing input lines
-R Run PHP for every input line
-F Parse and execute for every input line
-E <end_code> Run PHP <end_code> after processing all input lines
-H Hide any passed arguments from external tools.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z Load Zend extension .

args… Arguments passed to script. Use – args when first argument
starts with - or script is read from stdin

–ini Show configuration file names

–rf Show information about function .
–rc Show information about class .
–re Show information about extension .
–ri Show configuration for extension ."][/quote]

I have tried pointing to instead of .php but get exactly the same.

Any suggestions?

Many thanks in advance.



Don’t use the flag “-f”


0 * * * * /usr/local/bin/php -f /home/mydomain/mysite/piwik/misc/cron/archive.php --url=


0 * * * * /usr/local/bin/php /home/mydomain/mysite/piwik/misc/cron/archive.php --url=


Hi everyone,

I also have a problem running the archive script.
If I call the script directly in the working directory via

php5 archive.php --url=

everything works fine. But when I install the cronjob, and I call the script via

php5 /var/www/........./archive.php --url=

I just get the following:

(13:26:42) [~] php5 /var/www/......../archive.php --url=
X-Powered-By: PHP/5.2.13
Content-Type: text/html; charset=utf-8

[2012-02-29 12:26:59] [219da620]
[2012-02-29 12:26:59] [219da620] Usage:
[2012-02-29 12:26:59] [219da620]        /path/to/cli/php "/var/www/......./archive.php" --url= [arguments]
[2012-02-29 12:26:59] [219da620]
[2012-02-29 12:26:59] [219da620] Arguments:
[2012-02-29 12:26:59] [219da620]        --url=[piwik-server-url]
[2012-02-29 12:26:59] [219da620]                        Mandatory argument. Must be set to the Piwik base URL.
[2012-02-29 12:26:59] [219da620]                        For example: --url= or --url=
[2012-02-29 12:26:59] [219da620]        --force-all-websites
[2012-02-29 12:26:59] [219da620]                        If specified, the script will trigger archiving on all websites.
[2012-02-29 12:26:59] [219da620]                        This can be used along with --force-all-periods to trigger archiving on all websites and all periods.
[2012-02-29 12:26:59] [219da620]        --force-all-periods[=seconds]
[2012-02-29 12:26:59] [219da620]                        Triggers archiving on websites with some traffic in the last [seconds] seconds.
[2012-02-29 12:26:59] [219da620]                        [seconds] defaults to 604800 which is 7 days.
[2012-02-29 12:26:59] [219da620]                        For example: --force-all-periods=86400 will archive websites that had visits in the last 24 hours.
[2012-02-29 12:26:59] [219da620]        --force-timeout-for-periods=[seconds]
[2012-02-29 12:26:59] [219da620]                        The current week/ current month/ current year will be processed at most every [seconds].
[2012-02-29 12:26:59] [219da620]                        If not specified, defaults to 3600.
[2012-02-29 12:26:59] [219da620]        --accept-invalid-ssl-certificate
[2012-02-29 12:26:59] [219da620]                        It is _NOT_ recommended to use this argument. Instead, you should use a valid SSL certificate!
[2012-02-29 12:26:59] [219da620]                        It can be useful if you specified --url=https://... or if you are using Piwik with force_ssl=1
[2012-02-29 12:26:59] [219da620]        --help
[2012-02-29 12:26:59] [219da620]                        Displays usage
[2012-02-29 12:26:59] [219da620]
[2012-02-29 12:26:59] [219da620] Notes:
[2012-02-29 12:26:59] [219da620]        * It is recommended to run the script with the argument --url=[piwik-server-url] only. Other arguments are not required.
[2012-02-29 12:26:59] [219da620]        * This script should be executed every hour via crontab, or as a deamon.
[2012-02-29 12:26:59] [219da620]        * You can also run it via http:// by specifying the Super User &token_auth=XYZ as a parameter ('Web Cron'),
[2012-02-29 12:26:59] [219da620]          but it is recommended to run it via command line/CLI instead.
[2012-02-29 12:26:59] [219da620]        * If you use Piwik to track dozens/hundreds of websites, please let the team know at
[2012-02-29 12:26:59] [219da620]          it makes us happy to learn successful user stories :)
[2012-02-29 12:26:59] [219da620]        * Enjoy!
[2012-02-29 12:26:59] [219da620]

Any ideas why this happens?



Thanks for the reply, I just did what you suggested but now the e mail I get is the following:

Piwik › Error
Piwik # web analytics

Piwik couldn't write to some directories.

Try to Execute the following commands on your server:

chmod 0777 /home/mydomain/
chmod 0777 /home/mydomain/
chmod 0777 /home/mydomain/
chmod 0777 /home/mydomain/

If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0777 (with your FTP software, right click on the directories, permissions).

After applying the modifications, you can refresh the page.

If you need more help, try

Go to Piwik


Please put the output in a html-file and open it in a browser. Then you will get some more information.

It seams that the user is not allowed to write in the tmp-dir.


Please try to set your config as the usage.
That means, put the url in double quotes.


I have got it to work but setting the folder permissions to 777 which is a bit insecure, I hope this can be resolved in future versions.


I’ve got it on 750. So it depends on your needs and configuration.