o

HomeGuides › Matomo

Setting up a Matomo cronjob: archiving reports automatically

Matomo condenses the collected raw data into reports. That is called archiving, and without a schedule it only happens when somebody opens the report. This guide shows how to trigger archiving from outside, once an hour.

Why at all

Whoever opens the report pays the computing time

Out of the box Matomo computes a report the moment somebody requests it. On a small site you barely notice. As soon as a few thousand visits a day pile up, that becomes a wait of several seconds, every time, for everyone who opens the dashboard.

It also affects every evaluation nobody opens by hand: the email reports Matomo sends, the segments, and the data other programs fetch through the API. They are only as current as the last call.

The solution turns it around: a fixed call from outside computes the reports in advance. Whoever opens the dashboard then sees finished figures immediately.

URL to call
https://ihre-domain.de/matomo/misc/cron/archive.php
Recommended interval
hourly
Tested with
Matomo 4.x, 5.x
Sufficient plan
The free plan is enough for an hourly call. The request body carrying the token needs Plus or Unlimited.

Setup

Step by step

The AI does it faster

You do not have to transfer any of this by hand. Paste this guide – or the one for your own system – into the assistant, and Cronjob.de fills in address, method, schedule and headers. Where something is unclear it asks instead of guessing. At the end you see what was entered and create the job with one click.

Included in the free plan at no extra cost. You will find it after signing in under "Cronjobs" → "Create with AI".

  1. Create a token for authentication

    Sign in as superuser and go to Administration → Personal → Security. Create a new token under "Auth tokens" at the bottom and write down the 32 characters – Matomo shows them only once.

  2. Disable browser archiving

    Under Administration → System → General settings set "Archive reports when viewed from the browser" to No and "Archive reports at most every X seconds" to 3600. Without this step Matomo keeps computing on every request.

  3. Create an account at Cronjob.de

    Registration takes a minute and is free. Three cronjobs stay free forever, the first 14 days run on the Unlimited plan.

  4. Create the cronjob – the token belongs in the body

    Enter https://your-domain.com/matomo/misc/cron/archive.php as the address, choose POST as the method and put the token into the request body. Matomo explicitly recommends this so the token does not end up in server logs and history lists. A fixed minute of every hour is enough as a schedule.

    token_auth=YOUR32CHARACTERTOKEN
    
    # schedule, hourly at :17
    17 * * * *
  5. Switch on error notifications

    Enter an email address in the folder settings. When archiving fails your reports go stale silently – without a notification you notice weeks later.

Verification

Is it actually running?

After the first run the Cronjob.de call log shows the archiver output, ending in a summary ("Done archiving!"). Inside Matomo, Administration → System → General settings shows the time of the last successful archiving. An old timestamp there means the call is not arriving.

FAQ

Common questions about Matomo

Archiving takes longer than a minute. Does it get cut off?
The call from outside ends after 45 seconds (free) or 60 seconds (Plus and Unlimited). Matomo keeps running on your server if PHP does not watch the connection – set ignore_user_abort = On in php.ini for that. For very large installations Matomo recommends the command line anyway; archiving can take hours there.
Why hourly and not every five minutes?
Because Matomo only recomputes the reports once an hour anyway once you set "at most every 3600 seconds". More frequent calls only create load without making the figures any newer. If you need reports closer to real time, lower both values together.
Does the token really have to go in the body?
It does not have to, Matomo also accepts it as a parameter in the address. But it is Matomo's own recommendation: an address appears in access logs, in error messages and in the list of your cronjobs. A token in the body does not.
I get error 401 or "token_auth is invalid".
Then the token does not belong to a superuser, or it has since been deleted. Create a new one under Administration → Personal → Security. Make sure no space is copied along with it.
Can I call the API address instead of archive.php?
Yes, ?module=API&method=CoreAdminHome.runScheduledTasks triggers the scheduled tasks, such as sending the email reports. That is not the same as archiving though. For reports that should load quickly, archive.php is the right way.
I run Matomo for several sites. Does that change anything?
No, archive.php works through all sites of your installation one after another. It may just make the run take longer than the window of a single call – see the first question.

Create your cronjob now

Create an account, enter the address, click the schedule. Three cronjobs are free forever, the first 14 days run on the Unlimited plan.

Start for free See pricing

More guides

Official documentation of Matomo

The details about Matomo come from their own documentation, as of September 2026. Please check there whether anything has changed since.